Mega Code Archive

 
Categories / Php / Form
 

Using a hidden parameter to indicate form submission

<? if ($_POST['_submit_check']) {     process_form(); } else {     show_form(); } function process_form() {     print "Hello, ". $_POST['my_name']; } function show_form() {     print<<<_HTML_ <form method="POST" action="$_SERVER[PHP_SELF]"> Your name: <input type="text" name="my_name"> <br/> <input type="submit" value="Say Hello"> <input type="hidden" name="_submit_check" value="1"> </form> _HTML_; } ?>