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!
I know this going to sound really dumb! but i'm still new at this.
I have a HTML form to enter information and it has 3 buttons (ADD,Edit and Delete). This form calls the php script to do the work. I have the Add button working fine but i don't know how to incorporate the other two into the script?
I think he has three submit buttons so (if I'm completely wide of the mark in answering this question just let me say the same as llimllib in that more info would've been nice)...
if ($result==$save)
{
mysql_close($db);
echo "<b>Saving Client Information was a Success!</b> ";
}
if(!$result)
{
echo "<b>Client Information not added!</b> ", mysql_error();
exit;
}
?>
so if $result = $query and that query is doing the adding to the database, then how do i do the edit and delete queries with the $result?
Mac, you want to be careful with that. IIRC, browsers aren't required to send the name of the submit button with a form; and I'm pretty sure that some browsers don't send it.
As for your form, the easiest way for you to do it is to have a separate form for each action, or to have the user check which action he wants to complete, and then only one submit button.
Finally, you don't use the $result to edit or delete; at the top of your form you check what action the user selected, and perform a different query for each one based on that.
I suppose I should've added an 'only tested on IE 6 'cos that's what I'm working on right now disclaimer' . I prefer to have three separate forms for adding, editing and deleting (obviously built dynamically to reduce effort) as there's less chance of doing the wrong action (and causing lots of damage) that way.