php - Trying to eliminate a character -


$message=$this->filter($_post['suggestion']);  protected function filter($mail) {     if(strpos($mail,"<") !== false)     {         $mail = "message entered invalid";     }     else     {         $mail = $mail;     }      return $mail; }  

sure i'm doing wrong here, if $_post["suggestion"] contains "<" should return predefined message. doesn't work: return same message regardless if "<" in there or not.

you use preg_match

function filter($mail) {     if(preg_match("/</", $mail))     {       $mail="message entered invalid";      }     return $mail; } 

http://php.net/manual/en/function.preg-match.php


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -