PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
vchris
Forum Contributor
Posts: 204 Joined: Tue Aug 30, 2005 7:53 pm
Location: Canada, Quebec
Post
by vchris » Sat Sep 10, 2005 7:19 pm
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:
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..."
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Sep 10, 2005 7:23 pm
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.
vchris
Forum Contributor
Posts: 204 Joined: Tue Aug 30, 2005 7:53 pm
Location: Canada, Quebec
Post
by vchris » Sat Sep 10, 2005 7:26 pm
I have read about that on a website and I have tried doing the following if statement as well:
But it still doesn't work. I get the error:
"Notice: Undefined index: submit_x"
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Sep 10, 2005 7:27 pm
did you look at a var_export() of $_POST ?
vchris
Forum Contributor
Posts: 204 Joined: Tue Aug 30, 2005 7:53 pm
Location: Canada, Quebec
Post
by vchris » Sat Sep 10, 2005 7:31 pm
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.
vchris
Forum Contributor
Posts: 204 Joined: Tue Aug 30, 2005 7:53 pm
Location: Canada, Quebec
Post
by vchris » Sat Sep 10, 2005 7:32 pm
actually displays the value on screen.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Sep 10, 2005 7:50 pm
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.
Figure out which one of those found it and use that one
vchris
Forum Contributor
Posts: 204 Joined: Tue Aug 30, 2005 7:53 pm
Location: Canada, Quebec
Post
by vchris » Sun Sep 11, 2005 10:44 am
I have tested my new if statement and it seems to work properly.
I basically added "_x" after the field name. Is this the correct way of doing it?