Page 1 of 1

Multiple Graphical Submit Buttons

Posted: Sat Sep 10, 2005 7:19 pm
by vchris
I have a form which has 2 graphical submit buttons.

One will update the record and the other cancel the operation and redirect to another page.

I don't know how to verify which one was clicked.

Here is my PHP if statement:

Code: Select all

if($_POST['submit']){...
Here is my html code:

Code: Select all

<input type="image" name="cancel" src="images/btncancel.jpg" border="0">
<input type="image" name="submit" src="images/btnupdate.jpg" border="0">
The error I get is:
"Notice: Undefined index: submit in..."

Posted: Sat Sep 10, 2005 7:23 pm
by feyd
the x and y coordinates are used when submission is done through an image.. look through a var_export() of $_POST to see what I mean.

Posted: Sat Sep 10, 2005 7:26 pm
by vchris
I have read about that on a website and I have tried doing the following if statement as well:

Code: Select all

if($_POST['submit_x']){
But it still doesn't work. I get the error:
"Notice: Undefined index: submit_x"

Posted: Sat Sep 10, 2005 7:27 pm
by feyd
did you look at a var_export() of $_POST ?

Posted: Sat Sep 10, 2005 7:31 pm
by vchris
Yes. I checked php.net.

I tried the following:

Code: Select all

if(var_export($_POST['submit'])){
and
if(var_export($_POST['submit_x'])){
and
if(var_export($_POST['submit_y'])){
doesn't work.

Posted: Sat Sep 10, 2005 7:32 pm
by vchris
actually displays the value on screen.

Posted: Sat Sep 10, 2005 7:50 pm
by feyd
I suggested var_export() so you could see what data was coming in as, not to use it as a means to actually check if the data is there, silly. :P

Figure out which one of those found it and use that one ;)

Posted: Sun Sep 11, 2005 10:44 am
by vchris
I have tested my new if statement and it seems to work properly.

Code: Select all

if(isset($_POST['submit_x'])){
I basically added "_x" after the field name. Is this the correct way of doing it?