RE: [PHP] Multiple Form Submit Buttons

2002-10-11 Thread Jay Blanchard

[snip]

I have been digging through the documentation for a while, but I can't find
the answer to this ...

If I have a form with multiple submit buttons, how can I tell in PHP which
button was clicked?
[/snip]

Use a switch/case statement;

switch($action)
{
case "Save":
// query to insert saved elements only
$qsave = "UPDATE tblArticle ";
$qsave .= "SET title = '$title', ";
$qsave .= "teaser = '$teaser', ";
$qsave .= "body = '$body' ";
$qsave .= "WHERE ID = '$aid' ";

if(!($dbsave = mysql_query($qsave, $dbconnect))){
print("MySQL reports: " . mysql_error() . "\n");
exit();
}

break;

case "Submit Article":
//query to submit article
$qsubmit = "UPDATE tblArticle ";
$qsubmit .= "SET title = '$title', ";
$qsubmit .= "teaser = '$teaser', ";
$qsubmit .= "body = '$body', ";
$qsubmit .= "type = '$type' ";
$qsubmit .= "WHERE ID = '$aid' ";

if(!($dbsubmit = mysql_query($qsubmit, $dbconnect))){
print("MySQL reports: " . mysql_error() . "\n");
exit();
}

Each of the buttons is named "action" and based on the value the script
processes accordingly.

HTH!

Jay



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Multiple Form Submit Buttons

2002-10-11 Thread Jonathan Rosenberg

I have been digging through the documentation for a while, but I can't find
the answer to this ...

If I have a form with multiple submit buttons, how can I tell in PHP which
button was clicked?

--
JR



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php