Hi,
I am attempting to use PHP to search for a list of possible values that must be entered from a text box on a sign up form. However, the user is still allowed to enter other text, as long as he or she also enters one of the predetermined values that I am searching their input for. If the user's input doesn't contain one of the predetermined value, an error message is returned. However, it doesn't seem to work with the multiple "Or" statements. Is there a better way of doing this? I've searched all over the web and on here and I'm still stuck.
Here is what I have so far:
$string = "Northwestern School Corporation"; //should trigger as true below
$newString = ereg_replace("[^A-Za-z0-9]", "", strtolower($string)); //strips spaces out
echo $newString."<br />";
//Supposed to match any of the following as true and return the error message.
if (
(stristr($newString, 'elementary') === false) ||
(stristr($newString, 'school') === false) ||
(stristr($newString, 'middle') === false) ||
(stristr($newString, 'high') === false) ||
(stristr($newString, 'college') === false) ||
(stristr($newString, 'university') === false)
) {
echo "Must contain one of the following: Elementary, School, Middle School, High School, College, or University";
} else {
//Valid School
echo "Valid school.";
}