forms - I want to use regular expression in php -
i want know how give user error on form validation if <
or >
used in form fields. here script:
$pattern = "<,>"; if (preg_match($pattern, $_post["u"])) { exit("this illegal, error!!!"); }
use [<>]
if (preg_match('/[<>]/', $_post["u"])) { // illegal char }
however there no need use regular expressions. can use strpos:
if (strpos($_post["u"], '<') !== false || strpos($_post["u"], '>') !== false) { // illegal char }
Comments
Post a Comment