hi… i’ve got a site whose content depends on the value of a parameter in the URL. for example:
[font=Courier New]www.example.com/?section=contact[/font]
i want to prevent someone from manually entering a section that doesn’t exist, by checking the $section variable in the URL against a list of valid categories. if the value entered is not in the list, i want $section to equal “index” so that they will simply go to the home page. i tried this:
[font=Courier New]if ($section != “index”, “contact”, “photos”) {
$section = “index”;
}
[font=Verdana]
but it doesn’t work. is there a better way to do this than listing each section manually? i actually have quite a few categories, not just the three listed here, so i don’t want to have this giant conditional statement. however, the only way i CAN think of to solve this problem is to make a giant conditional statement, like this:[/font]
[/font][font=Courier New]if (($section != “index”) || [/font][font=Courier New]($section != “contact”) || [/font][font=Courier New]($section != “photos”)) [/font][font=Courier New] {
$section = “index”;
}
[font=Verdana]it seems like a kludgy way to do it, but i’m not sure how else to write it. anyone have a simpler solution?[/font]
[/font]