log in problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gpong
Forum Newbie
Posts: 16
Joined: Sun Aug 06, 2006 8:49 am

log in problem

Post by gpong »

I make login system and I want to verifying that username can't use blank space or "/" and other symbol. how to solve this problem?? thanks very much
User avatar
veridicus
Forum Commoner
Posts: 86
Joined: Fri Feb 23, 2007 9:16 am

Post by veridicus »

I typically validate usernames with a single regex (preg_match) that checks length and valid characters.
gpong
Forum Newbie
Posts: 16
Joined: Sun Aug 06, 2006 8:49 am

Post by gpong »

can you give example how to use it. thanks very much.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

ctype_alpha() && strlen() is what I would use
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

I'd go the regex route with preg_match()

something like this maybe?

untested:

Code: Select all

$pattern = "/(\/|\s+)/";
Post Reply