February 2008
Intermediate to advanced
216 pages
4h 33m
English
Occasionally you want a form that does two separate things depending on which button a user clicks—one button updates a post while the other button deletes it. You can put two forms on one page that will send the user to two separate pages, but then you have to worry about inserting redundant information into both forms, not to mention that this would be unbearable to the user.
In HTML, buttons also have values, and you can read those values. Construct your form as follows:
<form action="process.php" method="post"> <input name="postid" type="hidden" value="1234"> <input name="action" type="submit" value="Update"> <input name="action" type="submit" value="Delete"> </form>
Now, in process.php, access $_POST['action'] ...
Read now
Unlock full access