How to do a cancel button in the form and redirect to another page

S

Steven

I try to put a submit and cancel button in the form. For submit it will
execte the script in action. For cancel, would like to cancel the whole
form and redirect to another page.

Any help will be appreciated.

-Steven
 
D

David Dorward

Steven said:
I try to put a submit and cancel button in the form. For submit it will
execte the script in action. For cancel, would like to cancel the whole
form and redirect to another page.

<input type="submit" name="s" value="Submit">
<input type="submit" name="s" value="Cancel">

<?php

if ($_POST('s') == "Submit") {
// Do something
} else if $_POST('s') == "Cancel") {
header('Location: http://localhost/somepage');
} else {
// Throw an error
}

?>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top