I am trying to make a simple form that when certain text is entered it will redirect to another page.
Form:
<form action="goto.php" method="post">
Destination: <input type="text" name="destination">
<input type="submit">
</form>
I am unsure of how to set up goto.php
to achieve the desired result. I basically want something like the following:
<?php
if ($_POST["destination"]="mail" ) {
header( 'Location: /mail/' );
} elseif ($_POST["destination"]="forms") {
header( 'Location: /forms/' );
} else {
echo "Invalid";
}
?>
However, this doesn't work because the way header();
works makes the form go to /mail/
no matter what text is entered. How can I resolve this to achieve my desired result?