Page 1 of 1

Using button images for multiple submit buttons.

Posted: Sun Jul 14, 2002 9:52 am
by Bill H
I can use images just fine if the form has only one submit input, but how can I do it when it has two?
My plan is the user clicks on an item in the list and then clicks a button to either revise it or delete it.

Code: Select all

print("<table>\n<form method=post action=clntdata.php>\n");
print("<tr><td width=240 colspan=3>");
	 
$Query = "SELECT id,Name FROM Inst ORDER BY Name";
$Result = mysql_query($Query, $Link);
print("<SELECT NAME=Inum SIZE=8>\n");
while ($row = mysql_fetch_array($Result))
     print("<OPTION VALUE=$row&#1111;id]>$row&#1111;Name]</OPTION>\n");
print("</SELECT>\n");

print("</td></tr>\n<tr><td width=70 align=left>\n");
print("<INPUT TYPE=SUBMIT Name=Submit VALUE=Delete>");
print("</td>\n<td width=100 align=left>\n");
print("<INPUT TYPE=SUBMIT Name=Submit VALUE=Revise>");
print("</td><td width=70>&nbsp;</td></tr>");
print("</form>\n</table>");
The above works fine -- $_POST['Submit'] contains either "Delete" or "Revise" depending on which button the user clicked.

Code: Select all

print("<INPUT TYPE=SUBMIT Name=Submit VALUE=Delete SRC=button1.gif>");
For that code the $_POST['Submit'] does not contain "Delete."

Posted: Mon Jul 15, 2002 2:03 am
by gnu2php
When you use an image as a submit button, PHP adds _x and _y to the name of the button (to mark the coordinates the button was clicked).

Use var_dump($_POST) to see what I mean.