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

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -