mbrown Posted January 31, 2009 Share Posted January 31, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/143264-validation/ Share on other sites More sharing options...
RichardRotterdam Posted January 31, 2009 Share Posted January 31, 2009 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 } Quote Link to comment https://forums.phpfreaks.com/topic/143264-validation/#findComment-751325 Share on other sites More sharing options...
mbrown Posted January 31, 2009 Author Share Posted January 31, 2009 thank you that works out alot better. what was the other way you were telling me? Quote Link to comment https://forums.phpfreaks.com/topic/143264-validation/#findComment-751336 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.