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
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...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.