Rob wrote:
Im having some troubles. When a user selects a topic from a drop down
I want it so that when they click submit it brings them to a
corresponding html page
so if they select plumbing then hit submit take then to plumbing.html
How do i pass variables to the header fucntion
<?php
$allowed_pages = array(
'plumbing',
'gardening',
'lightning',
'etcetera',
);
if (isset($_POST['topic'])) {
$var = $_POST['topic']; /* ex. 'plumbing' */
if (in_array(strtolower($var), $allowed_pages)) {
header('Location: http://yourserver.com/' . $var);
exit('Redirected to <a href="' . $var . '">' . $var . '</a>.');
} else {
/* Uh! Oh! */
/* user is messing with the form */
/* either re-show form or ban the user :-) */
}
}
/* user didn't select a topic */
/* re-show form, maybe with a error field */
?>
Remember to *NOT* output anything to the browser before the header()
call or it will give an error and fail to redirect the browser.
--
Mail to my "From:" address is readable by all at
http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!