WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : E-mail address check
Categories : PHP, Email, Regexps Click here to Update Your Picture
Olaf Lederer
Date : May 25th 2005
Grade : 2 of 5 (graded 4 times)
Viewed : 9596
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Olaf Lederer
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

This simple function validates an e-mail address first by checking against a regular expression and second that the mail host exists. The DNS check fails if there is no MX record for the tested e-mail address. This function is an optimum validation for contact forms, CMS and member systems. Don't forget that the function "checkdnsrr" will not work on windows servers.

<?php
function check_email($mail_address) {
   
$pattern = "/^[\w-]+(\.[\w-]+)*@";
   
$pattern .= "([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4})$/i";
    if (
preg_match($pattern, $mail_address)) {
       
$parts = explode("@", $mail_address);
        if (
checkdnsrr($parts[1], "MX")){
            echo
"The e-mail address is valid.";
           
// return true;
       
} else {
            echo
"The e-mail host is not valid.";
           
// return false;
       
}
    } else {
        echo
"The e-mail address contains invalid charcters.";
       
// return false;
   
}
}
check_email("INFO@google.co.uk");
?>



email validator check checker email e-mail email address
Categories : PHP, Email, Regexps
validateEmail 2.0 - upgraded version of the old validateEmail function used to validate email addresses via SMTP and regex.
Categories : Email, Regexps, PHP
making links from text
Categories : PHP, Regexps, Email
Clever Email Validation Function - E-Mail validation function with an eregi expression and socket connection.
Categories : Email, PHP, Regexps
Tag content retrieval from websites with preg_match
Categories : PHP, Regexps, Arrays, HTML and PHP
email new items in db
Categories : PHP, Email, Databases, MySQL, Beginner Guides
This script is a contact form between users of a website (kinda like the PM function on the forums)
Categories : PHP, Databases, MySQL, Regexps
Simple way to replace a variable value in a .conf (.ini) file using a webbrowser - the first stage of a complete universal configuration editor
Categories : PHP, Regexps, Code Editors, Filesystem
ereg -- Regular expression match
Categories : PHP, PHP Functions, Regexps
Class for sending mail with MIME attachments in multipart format using external sendmail, mimencode and zip
Categories : Email, Network, PHP, PHP Classes
Gets the browser and OS from the $_SERVER['http_user_agent'] variable in PHP
Categories : PHP, HTTP, Regexps
a PHP Function to Get only the filename (remove the extension) using regular expressions.
Categories : PHP, Regexps, Beginner Guides
PHP Script to find url links in a page
Categories : PHP, URLs, Regexps, Arrays
A web-based php3 IMAP email client supporting address books, attachements (downloading and sending), LDAP searching, and much much more.
Categories : Email, PHP, LDAP
Encoding data using PGP via PHP's proc_* functions
Categories : Cryptography, Security, Email, PHP, PGP
 Indiana Jones wrote :1748
This Script is not RFC 2822 Valid.
Emails like:

jeff^lobster@domain.com
jeff’lobster@domain.com
jeff’lobster{yummy}@domain.com

are valid RFC 2822 email adresses but will be flaged as incorrect by this script.