Validation

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
bajaber
Forum Newbie
Posts: 6
Joined: Thu Apr 15, 2004 1:11 pm

Validation

Post by bajaber »

Again on the guestbook am working for i would like to make a validation for it, especially for the user name and the email input, pls somebody help. coz i have tried a few scripts but all invain :?:
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

It depends on what type of validation really. For simple stuff like checking usernames have no spaces or 'funny' characters then the ctype functions cover most cases.
Validating email addresses can range from a few lines to scripts 100's of lines long.
If you want to check a username isn't taken then you're into database queries etc to validate.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

most "specific' validation details can/are done with regular expressions.

ie:

ereg("^[_a-zA-Z0-9-]+$", $username)

Verifys that the name entered is text characters, not for example, backslashes, etc.
Post Reply