Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 30th, 2005, 05:44 PM
Authorized User
 
Join Date: Dec 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default Validating an email address

I know how to do it the hard way, but is there a simple, magic way to validate an email address in PHP?

TIA...

 
Old March 31st, 2005, 03:00 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

May start with
http://www.webreference.com/js/column5/

 
Old March 31st, 2005, 11:14 AM
Authorized User
 
Join Date: Dec 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

After some more digging, I answered my own question with:

function validate_email($email)
        {
       $exp = "^[a-z\'0-9]+([._-][a-z\'0-9]+)*@([a-z0-9]+([._-][a-z0-9]+))+$";
       if(eregi($exp,$email))
        {
        if(checkdnsrr(array_pop(explode("@",$email)),"MX") )
            {
                return true;
            }
        else
            {
                return false;
            }

        }
        else
            {
                return false;
            }
        }







Similar Threads
Thread Thread Starter Forum Replies Last Post
validate email address dartcoach Javascript 0 April 28th, 2008 12:58 PM
Validate Email address richardtr BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 6 November 23rd, 2004 01:45 PM
Is there anyway to get my email address removed jayirvin Forum and Wrox.com Feedback 8 April 16th, 2004 09:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.