Entry
How do I redirect a brower to the approtite page pendding on user input from a form?
Oct 16th, 2004 15:32
Philip Olson, Glenn Sams,
Assuming "answer" is the name of the form element, add various options
to the redirect array and it should work.
<?php
$baseurl = 'http://www.example.com/troubleshooting/';
$redirects = array('bad' => 'something-bad.html',
'good' => 'something-good.html',
'other' => 'other.html'
);
if (in_array($_POST['answer'], array_keys($redirects))) {
header('Location: ' . $baseurl . $redirects[$_POST['answer']];
exit;
} else {
echo "Not sure what to do, choose an appropriate action\n";
exit;
}
?>