Jump to content
xisto Community
Sign in to follow this  
sonesay

Validation Script - Detecting Illegal Characters preg_match to find illegal characters

Recommended Posts

I'm trying to validate a user's desired username for a registration page. I want to detect any illegal characters being used for a username. So far i have managed to include most execpt the '\', the '\' is used for escape and treating the preceding characters literally. I try to do '\\' but i get an error because it execects another character.

$ck_result = "Default";$pattern = "/[!|@|#|$|%|^|&|*|(|)|_|\-|=|+|\||,|.|\/|;|:|\'|\"|\[|\]|\{|\}]/i";	// check for inputif($uname == '') {$ck_result = "<span class='error_header'>Required!</span>";}else if (preg_match($pattern, $uname)) {$ck_result = "<span class='error_header'>illegal characters</span>";}

I have tried looking for more info but havent found any so far.

Notice from BuffaloHELP:
Always use proper bbcode tags. Title modified.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.