Hello everyone,
I am trying to create a form handling php script that, if a certain radio button is checked, you will be redirected to another location depending on which radio button was submitted.
This is sort of what I have, just changed text:
HTML CODE:
And then the PHP CODE that handles the form:
redirect.php
The solution would be greatly appreciated.
Thanks.
I am trying to create a form handling php script that, if a certain radio button is checked, you will be redirected to another location depending on which radio button was submitted.
This is sort of what I have, just changed text:
HTML CODE:
HTML:
<form action="redirect.php" method="post">
<input type="radio" name="item" value="books"
>Barnes & Noble
<input type="radio" name="item" value="clothes"
>American Eagle
<input type="submit" name="ok" value="OK" />
<input type="submit" name="cancel" value="Forget This Transaction" />
</form>
And then the PHP CODE that handles the form:
redirect.php
PHP:
<?php
$radio_selected = $_POST['item'];
if ($radio_selected == "books") {
header("Location: http://www.barnesandnoble.com");
}
else {
header("Location: http://www.ae.com");
}
?>
The solution would be greatly appreciated.
Thanks.