Validate Email

Email validation can be done in many ways. The most popular one is using regular expression which i'm writing here below.

If you are after more advance email validation. please visit here.

<?php

/* ** Script: To validate email ** */
/* ** Function: validate_email
** Input: email address
** Output : boolean
** Description: match the email with regular expression... */

function validate_email($email)

{
if(eregi("^[a-z0-9._-]+@+[a-z0-9._-]+.+[a-z]{2,3}$", $email))

return TRUE;

else return FALSE;

}

Description: Lets take an example, txtEmail is your textbox name which post the email address.

you receive your value using lets say: $email = $_POST["txtEmail"];

So if you are using inside a class ... you can use.. if($this->validate_email($this->email)) { // do something }