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.

CODE
$ck_result = "Default";
$pattern = "/[!|@|#|$|%|^|&|*|(|)|_|\-|=|+|\||,|.|\/|;|:|\'|\"|\[|\]|\{|\}]/i";
    
// check for input
if($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.

 

 

 


Reply