ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  PHP Form Handling
Subject:   Form submission question
Date:   2006-03-06 05:54:16
From:   miles&miles
Hi,


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?


Thanks



1 to 1 of 1
1 to 1 of 1