Jump to content


Photo

Checking username for bad characters


  • Please log in to reply
4 replies to this topic

#1 DarkendSoul

DarkendSoul
  • Members
  • PipPipPip
  • Advanced Member
  • 121 posts

Posted 18 August 2006 - 12:20 AM

Well when registering for an account I want it so your username can only have letters (caps/lower) and numbers along with _ (underscore) but i have no clue how i would do this... can someone help me out? :(

#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 18 August 2006 - 12:31 AM

$string = $_POST['usrnm'];

if (preg_match('/[^0-9a-zA-Z]/',$sting) === true){
// no you can't boyo!!!!
}
follow me on twitter @PHPsycho

#3 DarkendSoul

DarkendSoul
  • Members
  • PipPipPip
  • Advanced Member
  • 121 posts

Posted 18 August 2006 - 12:36 AM

thank you :) but by quick look at it it doesnt look like your aloud to use underscores :\

#4 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 18 August 2006 - 01:12 AM

ok ....

preg_match('/[^0-9a-zA-Z_]/'
follow me on twitter @PHPsycho

#5 DarkendSoul

DarkendSoul
  • Members
  • PipPipPip
  • Advanced Member
  • 121 posts

Posted 18 August 2006 - 04:18 AM

lol i hate preg_* their mixed searches get me so confused, i dont know what will and wont work...

thanks for the help, i think it'll work. :D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users