PHP Form Handling
Subject:   Form submission question
Date:   2006-03-06 05:54:16
From:   miles&miles

I am just a little bit confused about the submit check that the author talks about at the beginning of the article.

He says using the following code on the form:

<input type="hidden" name="_submit_check" value="1"/>

and then checking its presence with the following code:

if (array_key_exists('_submit_check', $_POST)) {
/* ... do something with the form parameters ... */

will avoid problems when users press enter instead of the submit button.

What I don't understand is what stops the hidden field being sent when enter is pressed. Basically I dont understand how using this code differentiates between a enter key or a submit button being pressed.

Can anyone clear this up for me?


Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • Form submission question
    2008-08-07 11:18:40  DeputyDawg [View]

    Some browsers only transmit the name/value pair for the submit form element when the submit button is clicked. If the form is submitted with the 'Enter' key, then the name/value pair for the submit element is not sent (method POST or GET).

    Only some browsers act this way. I believe IE 7.0 is one.

    I have experienced this problem with PHP5, but not with PHP4. Cannot explain that one.