I have a form in a PHP script and one text field. However when I press the enter key in a text field, the submit button does not set in the $_POST array.
But when I have two text fields in the form the submit button is set in the $_POST array.
This is happening in IE. Can anyone explain the reason behind this?
Below is the code I am testing with
<?php
print_r($_POST);
?>
<form action="" method="post" name="frmdata">
<input type="text" name="abc1" id="abc1" value="" size="20" maxlength="20"/>
<input type="text" name="abc" id="abc" value="" size="20" maxlength="20"/>
<input type="submit" name="submit1" value="submit1" id="submit1" />
</form>
If I remove one of the text box and submit the form by pressing enter key while entering text in the text box, IE does not set Submit button in $_POST array.
This does not set the Submit Button:-
<?php
print_r($_POST);
?>
<form action="" method="post" name="frmdata">
<input type="text" name="abc1" id="abc1" value="" size="20" maxlength="20"/>
<input type="submit" name="submit1" value="submit1" id="submit1" />
</form>
I actually got this while answering this question.
Thanks @Yaniro. It is a IE bug.
IE having bug with the single text element- That it is if you submit the form using the enter key the
Submitbutton will not set in$_POST.You must have at least 2 form element if you want
submit buttonto set in$_POSTwhen form submitted by pressing Enter key in IE.