"> ">
Previous Thread
Next Thread
Print Thread
Hop To
#135006 12/14/2001 5: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 7: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 12: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
"Recent Posts" box
by SenecaFlyer - 12/13/2024 12:06 PM
Sticky posts and global announcements
by Larry Miller - 12/08/2024 2:30 PM
Profile avatar storage settings
by SenecaFlyer - 12/05/2024 1:24 PM
Not allowing attachment over 2m
by ehill - 12/03/2024 3:16 PM
New Admin Here
by SenecaFlyer - 12/02/2024 4:14 PM
Who's Online Now
3 members (Ruben, SenecaFlyer, 1 invisible), 1,719 guests, and 157 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.0.1
(Snapshot build 20240918)