email address validation

wxdqz

New Member
hi,

i'm a newbie to PHP and have made a simple form mailer script which works very well but i would like to add some validation to it now.

Could someone please add an email validation scriptlet to my code and put an IF statement in there too that could redirect to different pages depending on if it was true or false.

My code is:

<?
/* Get Time */
$today = date("d/m/Y");

/* Send relevant emails */
mail("$emailto",
"$subject",
"<font face=arial><small>Generated by Krazy-Krew Contact page.<br><br>This message was sent to <b>$emailto</b> by <b><a href=http://www.phpbuilder.com/board/archive/index.php/mailto:$email>$name</a></b> on <b>$today</b><br><br>
Message:<br><b>$message</b><br><br>
<b>Krazy-Krew - <a href=http://www.krazy-krew.co.uk>www.krazy-krew.co.uk</a></b></small></font>",
"From: $name <$email>\nContent-Type: text/html; charset=iso-8859-1\n");

/* Thankyou page */
PRINT "<CENTER>";
PRINT "<img src=logo1.png><br><br>";
PRINT "<font class=newstext>Thank you <b>$name</b> for contacting us. We will reply shortly.";
PRINT "</CENTER>";
?>

I have found some validation code but i'm unsure how to do an IF statement in PHP with regard to the code. The validation code i found is:

function checkmail_mx ($email) {
if (eregi("^[_\.0-9a-z-]+@([0-9a-z][-0-9a-z\.]+)\.([a-z]{2,3}$)", $email, $check)) {
if (getmxrr($check[1].".".$check[2], $temp)) {
return true;
} else {
return false;
}
} else {
return false;
}
}

I would like this function to check the email address in the variable $email.

This is probably very simple, but i am a beginer.

Thank you in advance.

Rigo
 
Back
Top