5ury4 Posted March 26, 2007 Share Posted March 26, 2007 Hello everyone! I need simple help with the syntax of preg_match, what I'm trying to do is to see if the user inputs any special character that is -> "@#$%^&*()+=-[]\\\';,./{}|\" How should I preg_match this with a given variable say $userinput ? I tried this code, but the problem with it was though it deteced # and $ but it refused to detect ! and @. <? $userinput = "test"; if(preg_match("/\!\@\#\$\%\[\]/",$userinput)){ echo "Special Characters Found"; } else{ echo "No SPeical character found."; } ?> Thanks in advance. Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted March 26, 2007 Share Posted March 26, 2007 rather than including each special characters, wont it be easier to just include what you want, so the alphbets and numbers? if(!eregi("^([a-z0-9])*$",$lname)) {echo "invalid found!";} Quote Link to comment Share on other sites More sharing options...
5ury4 Posted March 26, 2007 Author Share Posted March 26, 2007 Thanks a lot that worked Quote Link to comment 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.