Jump to content

username/password characters


EXiT

Recommended Posts

to validate user input i personally use preg_match.

 

to validate your example you could use this pattern:

 

if(preg_match("/\A[A-Za-z0-9_-]{4,16}",$_POST['username']) != 1){
      echo("Username must be Letters,Numbers,dashes and underscores only, must also be wtween 4 and 16 characters long.");
}else{
      // Username Okay
}

 

http://uk.php.net/manual/en/reference.pcre.pattern.syntax.php for more information on perl-compatible php regular expressions.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.