Jump to content

[SOLVED] Code Explanation please ??


ali_2kool2002

Recommended Posts

Hi  can someone explain how the code works so at least i know how php does it instead of just using it from here

the first code checks if there are no numbers in the text field for name but what do those characters in preg match mean same applies for how does the email validation work? Thanks for anyone to crack this cheers :

 

if ( !preg_match('/^[a-zA-Z\" "]*$/', $yname) ) 
   {      
    error('Name is not Valid.\\n'.
            'Please try again.');
      }Repeat it for every text box u want to validate.

Use this for email validation:

Code:
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $yemail)){ 
  error("Invalid e-mail address");
}

Link to comment
https://forums.phpfreaks.com/topic/48015-solved-code-explanation-please/
Share on other sites

[_a-z0-9-] --> any letters, a-z, or numbers 0-9

(\.[_a-z0-9-]+) --> followed by a maybe a "." , and any letters/numbers

@[a-z0-9-] --> an @ symbol, followed by any letters/numbers

(\.[a-z0-9-]+) --> followed by maybe a ".", and any letters/numbers

(\.[a-z]{2,4}) --> followed by a dot, and any letters/numbers, thats between 2-4 characters long

if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $yemail)){ 
  error("Invalid e-mail address");
}

 

if that helps any...

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.