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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top