$name = "";
$email = "";
$completed = FALSE;
if (isset($_POST["submit"]))
{
include("connect.inc.php");
$name = cleaninput($_POST['name'],$myconnection);
$email = cleaninput($_POST['email'],$myconnection);
$feedback = "";
if (!$_POST["name"])
{
$feedback = "Please enter your name.
";
}
if (!$_POST["email"])
{
$feedback .= "Please enter your email address.
";
}
list($userName, $mailDomain) = split("@", $email);
if (!checkdnsrr($mailDomain, "MX"))
{
$feedback .= "Invalid Email Domain
";
}
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email))
{
$feedback .= "Your email address doesn't appear to be valid - please check and try again.
";
}
if ($feedback=="")
{
$sql = mysql_query("SELECT * FROM subscribers WHERE email='$email'");
$numRows = mysql_num_rows($sql);
if ($numRows>0)
{
$feedback = "That email address is already subscribed.";
}
}
if ($feedback=="")
{
$insertresult = mysql_query("INSERT INTO subscribers (name, email) VALUES ('$name', '$email')") or die (mysql_error());
if ($insertresult)
{
$completed = TRUE;
}
$customer_ip = $_SERVER['REMOTE_ADDR'];
$to = 'mail@merchantmcdonald.co.uk';//mikew@mustardgraphics.co.uk
$title = "Merchant McDonald Newsletter Sign Up! $mailingtime";
$header = "From: \"".$name."\" <".$email.">"; // Found elsewhere
$body = "You have a new subscriber, details below\r\n\r\n";
$body .= "".$name."\r\n";
$body.= "\r\n";
$body.= "".$email."\r\n";
mail($to,$title,$body,$header);
}
}
?>
Good Morning! - Thursday, 05 December 2024 |