"> ">
Previous Thread
Next Thread
Print Thread
Hop To
#135006 12/14/2001 6:50 PM
Anonymous
Unregistered
Anonymous
Unregistered
is mail adress verification a fiture of UBBthreads? <img border="0" title="" alt="[Confused]" src="images/icons/confused.gif" />

#135007 12/19/2001 8:02 PM
Anonymous
Unregistered
Anonymous
Unregistered
Hmm... I don't think it is, but you could implement a function like this:

<?

if ((!ereg(".+\@.+\..+", $email)) &#0124;&#0124; (!ereg("^[a-zA-Z0-9_@.-]+$", $email)))
echo "Invalid Email address";
else
echo "correct";

?>


If you want to be really fancy, here is some code that will validate it against an MX record...

// Set the form error check to false
$form_errors = array();

//E-Mail address verifications
// Make Email a required field
$Email = trim($Email);
if ($Email == "") {
$form_errors["required_Email"] = true;
}
elseif (!eregi("^([a-zA-Z0-9._-])+@([a-zA-Z0-9._-])+\.([a-zA-Z0-9._-])([a-zA-Z0-9._-])+", $Email)) {
$form_errors["Email_badformat"] = true;
}
// Attempt to resolve the MX host
else {
list($user, $domain) = split("@", $Email, 2);
if (! checkdnsrr($domain, "MX")) {
$form_errors["Email_badhost"] = true;
}
}

// Check if there are any errors
if (count($form_errors)) {
// If the user left the e-mail field blank
if ($form_errors["required_Email"]) {
echo("<font color=\"#ff0000\"><b>Your E-mail Address is required.</b></font>");
}
// If the format of the e-mail address is incorrect
elseif ($form_errors["Email_badformat"]) {
echo("<font color=\"#ff0000\"><b>Please enter a valid e-mail address.</b></font>");
}
// If the mail server of the address the user provided could not be contacted
elseif ($form_errors["Email_badhost"]) {
echo("<font color=\"#ff0000\"><b>Your E-mail address did not resolve to a working e-mail server.<br> Please enter a valid e-mail address.</b></font>");
}
}

#135008 12/23/2001 1:16 PM
Anonymous
Unregistered
Anonymous
Unregistered
Thanks! I translated the format-checking into ubbthreads-ese, and posted it on

threadsdev

Regards,
Max


Link Copied to Clipboard
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Recent Topics
Account Profile Settings?
by Simon_UK - 05/09/2025 6:26 PM
Need UBB support, server move, upgrade
by aldeer - 05/05/2025 10:52 AM
PostgreSQL vs mySQL
by DennyP - 04/30/2025 1:26 PM
Honestly Disappointed in v8
by - 04/22/2025 2:21 PM
Who's Online Now
0 members (), 630 guests, and 144 robots.
Key: Admin, Global Mod, Mod
Random Gallery Image
Latest Gallery Images
Ride safe!
Ride safe!
by Morgan, December 7
Los Angeles
Los Angeles
by isaac, August 6
3D Creations
3D Creations
by JAISP, December 30
Artistic structures
Artistic structures
by isaac, August 29
Powered by UBB.threads™ PHP Forum Software 8.1.0
(Snapshot build 20250209)