hi there!
i have a strange problem and maybe somebody can help me :
let's say I've a form ( with inputs, selects, submitbutton etc. ) which submits the data to the same physical file ( e.g. index.php ). when the user enters some data and submits the form, I check the $_REQUEST["submit"] variable for its value and if set, I work with the data. ( if ($_REQUEST["submit"]) { ... } ). And now the bug : when the user clicks ( with the mouse ) on the submitbutton everything works fine, but when the user just presses the enter ( or return) key, the form submits but the $_REQUEST["submit"] (submitbutton) variable is not set ( theres no javascript or anythign else - just a normal form ) ! does anybody have the same problem or - better - a solution ? Thanks in advance !
HoBro
PHP - FORM submit - ENTER vs. MOUSECLICK
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
It's a browser thing - some will register the submit button being clicked if enter is pressed others (I'm not totally sure but I think IE is the one) don't. One way to get around that is to pass a hidden variable in your form:
and then when the form is submitted, check for that rather than the submit button:
Mac
Code: Select all
<input type="hidden" name="action" value="post" />Code: Select all
if (isset($_POST['action']) && $_POST['action'] == 'post') {
// form has been submitted
} else {
// form has not been submitted
}