Jump to content

Validation


mbrown

Recommended Posts

	if ($building != "Hooverville" && $buildling != "Summitview" && $building != "WAMS" && $building != "WASHS" && $building != "Mowery" && $buildling != "Clayton Avenue" && $building != "Fairview Avenue")
				//Clayton Avenue; Summitview do not work atm. 
				{
					$errorMessage .= "The entered buliding name ($building), does not match one of buildings in our district, ";
					$errorMessage .= "They have to be one of the following: Hooverville, Summitview, WAMS, WASHS, Clayton Avenue or Fairview Avenue";
				}

 

When I edit the user and enter Summitview or Clayton Avenue it says it is invalid. But as you see if it correct.

 

Any help would be great!

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/143264-validation/
Share on other sites

thats one looooooong if statement

why not simply use the in_array function and put the building names in a array.

If these buildings fetched from a database it would be even tiedier to use the id's

 

$buildings=array();
$buildings[]="building1";
$buildings[]="building2";
$buildings[]="building3";
if(!in_array($building,$buildings)){
  //error message stuff here
}

Link to comment
https://forums.phpfreaks.com/topic/143264-validation/#findComment-751325
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.