SoFunction
Updated on 2025-02-28

Analysis of the reasons why the form cannot be submitted

Directly upload the code:

Copy the codeThe code is as follows:

<div >
<h4>Member Registration</h4>
<div class="formdiv">
<form method="post" action="?action=register" name="register" >
<dl>
<dt>Please fill in the following content carefully</dt>
<dd class="hasspan">
Username: <input type="text" name="username">
</dd>
<dd class="hasspan">
Password: <input type="password" name="pwd">
</dd>
<dd class="hasspan">
Confirm password: <input type="password" name="pwdagain">
</dd>
<dd >
<img src="img/face/" alt="Select avatar" >
<input type="hidden" name="touxiang" value="">
<label ></label>
</dd>
<dd style="margin-right:120px;">
Verification code: <input type="text" name="code">
<span>
<img src="" alt="code" name="code">
<a href="#code" >change one</a>
</span>
</dd>
<dd class="btns">
<input type="button" name="submit" value="registration">
<input type="button" name="quit" value="exit">
</dd>
</dl>
</form>
</div>
</div>

Submit the form data to this page, the following is js processing

Copy the codeThe code is as follows:

/*Register form submission*/
function formDeal()
{
var btnSubmit = ('submit');
var formId = ('registerForm');
= function()
{
//The submit() method of the form cannot submit the form
();
}

}

If the form is submitted, there is a prompt message on this page

Copy the codeThe code is as follows:

if(!empty($_GET['action']) && $_GET['action'] == 'register')
{
echo 'You submitted the data';
exit();
}

As a result, I didn't see the prompt message after testing for a long time. I thought the code was wrong or the method was written incorrectly. I checked it carefully and confirmed that there was no error in the official results document.

() cannot submit, so I have to change the type of btnSubmit to submit for the time being

Copy the codeThe code is as follows:

="submit"

I checked the information online, and the reasons are reduced to two points:

1. There cannot be a label with name=”submit” in the form

2. "enctype="multipart/form-data"" cannot be missing in the form

After testing, these two points are absurd and did not solve my problem (maybe my problem environment is different)

Later, I thought that the forum friends suggested that I change the ID of the registration button to name it without submitting it. After correction, the form is submitted normally and the prompt message appears.

Finally, the button's id should not be set to submit, otherwise it may cause confusion, resulting in the form's submit() method cannot submit the form. When naming IDs, it is best not to repeat the name with the existing API on the name to avoid unnecessary trouble.