Senin, 09 Februari 2009

Verify a User's Email Address Using PHP-1
By Joe Marini
March 18th 2003

Reader Rating: 8.1

We've all seen it happen.

You put up a registration page on your site, hoping that visitors will leave you their email addresses so that you can stay in touch with them when you've got a new product for sale. Or a new tutorial that they might be interested in. Or you want to send them some "information from carefully screened third parties with whom we maintain a strategic relationship." Or maybe you want something in return before you give them that valuable whitepaper that you spent two months completing.

Whatever the reason, you happily construct your registration page, set up a database table to track the incoming email addresses, and publish it live. And sure enough, the registrations start coming in.

To mickey@mouse.com. And donald@duck.com. And emailthis@hahaha.com. You get the idea -- users are registering with bogus email addresses at domains that don't even exist. Not only are you going to be sending mail to nonexistent addresses, but they clutter up your database and cause maintenance headaches because they need to be cleaned out.

Make Sure They're at Least Real
One way to help address this problem is to make sure that a user's email address actually corresponds to a real email domain. Using PHP, you can check the domain registration records to see if the domain a user submitted to your site is real. To do this, we'll use PHP's checkdnsrr function.

The checkdnsrr

function looks up the dns record for a given type, and a given host. It has this format:

int checkdnsrr(string host [,string type]);

This PHP function checks the DNS records for the given host to see if there are any records of the specified type. Note that the type parameter is optional, and if you don't supply it then the type defaults to "MX" (which means Mail Exchange). If any records are found, the function returns TRUE. Otherwise, it returns FALSE.

To use this function, you submit a potential email address to it and check the result, as shown below:

// take a given email address and split it into the
username and domain.
list($userName, $mailDomain) = split("@", $email);
if (checkdnsrr($mailDomain, "MX")) {
// this is a valid email domain!
}
else {
// this email domain doesn't exist! bad dog! no biscuit!
}


---------------------------------


Related :

UsingCrystalReports6
VerifyUserEmailAddressPHP-1
VerifyUserEmailAddressPHP-2
viewinformationvb2005
WatermarkImagesFlyPHP-1
WatermarkImagesFlyPHP-2
WhatAretheIssues
What-isMySQL
WhatSQLServerExpress
writefileinvb2005
WritingFileDialogBox
SimpleDatabasevb6
SQLServer2005fromVisualBasic6
SQLServer2005withPHP
SQLServerSecurityGuidelines
TransferringFiles
UsingCrystalReports6