Using a hidden parameter to indicate form submission : Hidden Field « Form « PHP






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_;
}
?>
  
  








Related examples in the same category

1.Saving State with a Hidden Field
2.Saving State with a Hidden Field