Validate email with PHP

Everything PHP.

Validate email with PHP

Postby Voodoochilli on Tue Dec 04, 2007 3:54 pm

Found some good code to quickly check if an email is valid:

Code: Select all
<?php
$email = "mail@example.com";
if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
  //send the email
}
else {
  echo "Invalid email address.";
}

?>
User avatar
Voodoochilli
Site Admin
 
Posts: 77
Joined: Tue Nov 27, 2007 9:52 am
Location: Hereford, UK

Re: Validate email with PHP

Postby cmcook on Tue Dec 18, 2007 4:39 pm

I use that exact same method myself lol, can't beat it, and geat idea to post it!
Academic: c-cook.BSc-hons.com
Photography: c-cook.com
My Company: Red Cherry Solutions
cmcook
 
Posts: 24
Joined: Sat Dec 01, 2007 1:52 pm
Location: Hereford, UK

Re: Validate email with PHP

Postby ethanjames on Fri Mar 13, 2009 7:45 am

I also check your coding.. It is nice.. Thanks for your sharing..

SEO services india
ethanjames
 
Posts: 2
Joined: Fri Mar 13, 2009 7:41 am

Re: Validate email with PHP

Postby Dawson Tyrone on Tue Jul 28, 2009 11:50 am

PHP validate email
script is an easy way to validate an email address. Use this quick and simple PHP regular expression for email validation. This is also case-insensitive, so it will treat all characters as lower case. It is a really easy way to check the syntax and format of an email address. Function will return TRUE if address is valid and FALSE if not.
Dawson Tyrone
 
Posts: 30
Joined: Mon Jun 29, 2009 11:38 am

Re: Validate email with PHP

Postby mukitpandey on Thu May 20, 2010 3:57 pm

I have found some problem here.It is a regular expression for email checking but when anyone give a invalid email like
name@saikat.com,where no domain of saikat is found,then how can any regex check the domain is either existent or not,so I feel to do with combobox with valid domain(like yahoo,gmail,hotmail) and also have an another option of regex,you can see my site to view the both option.
Thanks
Mukit,visit my website to see it

website design
mukitpandey
 
Posts: 1
Joined: Thu May 20, 2010 3:45 pm


Return to PHP Forum

Who is online

Users browsing this forum: No registered users and 0 guests

cron