RE: [PHP] multiple FORMS on same page problem.
| From: | Vail, Warren | Date: | Mon, 15 Sep 2003 20:30:59 +0000 |
| Subject: | RE: [PHP] multiple FORMS on same page problem. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-162661@lists.php.net to get a copy of this message | ||
I don't know of any rule that says you cannot have two submit button in the same form.
Of course, if you need to know which was clicked, you will either need to name them differently or
detect their values in your form processing routine. If the button is clicked that should take you
to another form simply do a redirect (after processing all $_POST information);
header("Location: new page");
exit; // I always use this because processing continues after header
good luck,
Warren Vail
-----Original Message-----
From: Golawala, Moiz M (IndSys, GE Interlogix)
[mailto:Moiz.Golawala@ge.com]
Sent: Monday, September 15, 2003 1:17 PM
To: php-general@lists.php.net
Subject: [PHP] multiple FORMS on same page problem.
I am creating a page with 2 buttons. One which will refresh the page and the other that will go to
another page. My problem that I need to put all the values into $_POST and have access to when any
of the 2 buttons are clicked.
If I use the button in 2 seperate form tags I don't have access to all the values in $_POST.
Please look at the code below:
file (page4.php):
<html>
<form action="page4.php" method=post>
<?php echo "this is page 4"; ?>
<input type=text name='someVal' value=''">
<input type='submit' value='page4 Submit'>
</form>
<form action="page5.php" method=post>
<input type='submit' value='page5 Submit'>
</form>
</html>
file(page5.php):
<?php
$val = $_POST['someVal'];
echo $val;
echo "this is page 5";
?>
I would like to see the variable 'someVal' in the $_POST of both "page4 Submit"
button and "page5 Submit" button. This code is a simplified version of the more
complecated code where a tonnes of other values are involved. Any help is appreciated.
Moiz
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php