Forum Moderators: coopster

Message Too Old, No Replies

email validation plus link to email box.

         

Flolondon

7:49 pm on May 9, 2006 (gmt 0)

10+ Year Member



does anyone know of any good scripts and tutorial with email validation and link to email box to fill in form... thanks..

henry0

8:30 pm on May 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I use something like this
I removed a few sections that you do not need
and did not test it, however it should work out of the box

NOTE: It uses getmxrr()
check the manual [us2.php.net]

<<<
// ************ EMAIL

$email=htmlentities($_POST['email']);
if (empty($email))
{
echo"<h3>The email field is empty!</h3><p>
<a href='../register.php'><b>Please try again</b></a>";

exit();
}

if (isset ($email) &&!empty ($email) )
{ // ends end of script
$regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";
if (!eregi($regexp, $email))
{
echo "The email should ONLY contain Alphanumerical Characters! (Alphabetical and numeric) And: @ and - or_ <br>
<b>You entered: $email</b><br>
<a href='../register.php'><b>Please try again</b></a>";

Exit();
}
else
{
include "../validate_email.php";
}
if ( validate_email($email))
{
echo"OK";
}
else
{
echo"Not OK";
}
}// ends above commented braket

// keep the function wherever you want and include it as shown above
// *********** End email

<?

function validate_email($email)
{
// Create the syntactical validation regular expression
$regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";

// Presume that the email is invalid
$valid = 0;

// Validate the syntax
if (eregi($regexp, $email))
{
list($username,$domaintld) = split("@",$email);
// Validate the domain
//if (getmxrr($domaintld,$mxrecords))
$valid = 1;
} else {
$valid = 0;
}

return $valid;

}

?>

>>>

Flolondon

9:15 am on May 10, 2006 (gmt 0)

10+ Year Member



ok thanks let me try...

Habtom

9:46 am on May 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Make use of checkdnsrr too. Here checkdnsrr [php.net]

Hab