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
From: Golawala, Moiz M (IndSys, GE Interlogix)
Sent: Monday, September 15, 2003 1:17 PM
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:
<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 action="page5.php" method=post>
<input type='submit' value='page5 Submit'>
$val = $_POST['someVal'];
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.
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php