note 28579 deleted from tutorial.forms by philip
| From: | philip@php.net | Date: | Mon, 27 Jan 2003 19:20:26 +0000 |
| Subject: | note 28579 deleted from tutorial.forms by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-42876@lists.php.net to get a copy of this message | ||
It is sometimes useful to have more than one SUBMIT button in a form so that PHP can detect which
one has been clicked and take appropriate action. The value of the SUBMIT button does not come via
$_POST or $_GET but it can be obtained using $_REQUEST. Example:
this is file TESTFORM.HTM:
---------------------------
<h1>Form to test button detection in PHP</h1>
<form name="form1" id="form1" method="post"
action="processtestform.php">
<input name="textfield" type="text" value="Enter text here"
size="25" maxlength="25" />
<br />
<input name="submit1" type="submit" id="submit1"
value="Submit (button 1)" />
<br />
<input name="submit2" type="submit" id="submit2"
value="Submit (button 2)" />
</form>
-----------------------------------------------------
This is file PROCESSTESTFORM.PHP:
-----------------------------------
<h1>Results of processing TESTFORM.HTM input</h1>
<?php
echo "textfield contents: " . $_POST["textfield"]."<br>";
echo "button used: " ;
echo @$_REQUEST["submit1"];
echo @$_REQUEST["submit2"];
?>
-----------------------------------------------------