GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 07-Jan-2009, 05:23
jack123 jack123 is offline
Account Disabled
 
Join Date: Jan 2009
Posts: 1
jack123 is an unknown quantity at this point

How do I check that......?


hi all,

How do I check that a valid email address is entered?

Thanks
  #2  
Old 07-Jan-2009, 11:04
Blake's Avatar
Blake Blake is offline
Member
 
Join Date: Nov 2005
Posts: 255
Blake is a jewel in the roughBlake is a jewel in the rough

Re: How do I check that......?


I've used this in the past:

PHP Code:

function validateUser($user)
    {
        $user_lc = strtolower($user);
        $legalCharacters = "abcdefghijklmnopqrstuvwxyz0123456789!#$%*/?|^{}`~&'+-=_.";
        $s = strlen($user);
        if ($s == 0) return false;
        if ($user[0] == '.' || $user[$s - 1] == '.') return false;
        else if (strpos($user, '..') !== false) return false;
        else for ($i = 0; $i < $s; $i++)
        {
            if (strpos($legalCharacters, $user_lc[$i]) === false) return false;
        }
        return true;
    }

    function check_address($email, &$error)
    {
        $atCount = substr_count($email, "@");
        if ($atCount != 1)
        {
            $error = "Invalid email address.";
            return false;
        }
        $atPos = strpos($email, '@');
        $user = substr($email, 0, $atPos);
        $domain = substr($email, $atPos + 1);
        if (!validateUser($user) || strlen($domain) == 0)
        {
            $error = "Invalid email address.";
            return false;              
        }
        else if (!checkdnsrr($domain,'MX'))
        {
            $error = "Could not find server '" . $domain . "'.  Please check your email address and try again.";
            return false;
        }
        else
        {
            return true;
        }
    } 


__________________
www.blake-foster.com
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MFC Check box-save the selections piyumali2004 MS Visual C++ / MFC Forum 0 24-Dec-2008 00:04
How Can I Check on Database asdfg Java Forum 6 01-Mar-2008 09:19
MFC combo check box does not work ktcm MS Visual C++ / MFC Forum 2 12-Aug-2007 10:18
firewall, check referer, no good dopee MySQL / PHP Forum 0 23-Dec-2004 10:46

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 15:10.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.