Skip to main content
April 5, 2006
Answered

Problem with dual buttons on a form

  • April 5, 2006
  • 1 reply
  • 345 views
Hello -

I have a single form with two buttons, currently named 'Button1' and 'Button2'. Both buttons lead through the default DW/php code to update database records (in MySQL), but I want the page redirect after updating to be determined by which button was pushed.

I am using $_GET['ButtonName'] to direct action based on which button was used to submit the form. Unfortunately, I can't seem to redirect the page where I want.

The code I am using is:

=======
if (isset($_GET['Button1'])) {
$updateGoTo = "edit_onepage.php";
} else {
$updateGoTo = "account.php";
}
========

If the user submits using Button1, I want them forwarded to "edit_onepage.php". If he submits using Button2, I want him forwarded to "account.php". Unfortunately, no matter how I fiddle with this code, the form is always forwarding to "account.php", regardless of which button is pushed.

Can anyone see what I am missing here? Thanks in advance for your advice.
This topic has been closed for replies.
Correct answer
Oops! Found my own mistake. It works if I retrive the button information with '$_POST', not '$_GET'. I'll leave this up in case anyone else has a similar porblem.

1 reply

Correct answer
April 5, 2006
Oops! Found my own mistake. It works if I retrive the button information with '$_POST', not '$_GET'. I'll leave this up in case anyone else has a similar porblem.
New Participant
April 17, 2006
I am having the same problem, but I am using VB Script on an Asp page. How can I tell which button is pressed in this scenario?