Can someone help me with this or explain it more.
I want to validate the variable $username. I want it to have only these values allowed:
A-Z
a-z
0-9
_
How could I do this? I got an idea, but I am so confused with the eregi(); command.
Also how can I make the variable $email have to be in the normal e-mail format with only these characters allowed:
A-Z
a-z
0-9
.
-
_
Thanks.
Validation Codes
Moderator: General Moderators
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
You chose the perfect characters for the \w metacharacter.
As for the email question, there's a tonne of available pattern out there to use - have a search 
Code: Select all
$var = 'sfdg6765_vgdz';
if (preg_match('/^\w+$/', $var)) echo 'Valid!';Re: Validation Codes
The RFC compliant email format uses more than just those characters. There are multiple RFC compliant validation formats that have been posted on these forums, including one I use.tecktalkcm0391 wrote:Also how can I make the variable $email have to be in the normal e-mail format with only these characters allowed