Hey guys,
I have no clue why this is happening. When someone would fill out the Name, Email, and Confirm Email it sends the second email to the user from their own email address not mine. Can someone please help me here?
"Thank you for entering to win 200 dollars. Please check this email address later to see if your the lucky winner!
Sincerely,"
Should say it was sent from [email protected]
Thanks for any help!
HTML:
[php]
ENTER TO WIN $200
|
Full Name:
|
Email Address:
|
Confrim Email:
|
|
[/php]
PHP:
[php]
<?php
// first clean up the input values
foreach($_POST as $key => $value) {
if(ini_get('magic_quotes_gpc'))
$_POST[$key] = stripslashes($_POST[$key]);
$_POST[$key] = htmlspecialchars(strip_tags($_POST[$key]));
}
$ip=$_SERVER['REMOTE_ADDR'];
$email_to = "
[email protected]";
$email_subject = "200 Entry | ";
$email_message .= "Name Entered: ".$_POST["fname"]."\n";
$email_message .= "Email Address: ".$_POST["lname"]."\n";
$email_message .= "Confirm Email: ".$_POST["email"]."\n";
$userEmail = filter_var( $_POST['email'],FILTER_VALIDATE_EMAIL );
if( ! $userEmail ){
exit;
}
//email headers
$headers = 'From: '.$_POST["email"]."\r\n".
'Reply-To: '.$_POST["email"]."\r\n" .
'X-Mailer: PHP/' . phpversion();
echo (mail($email_to, $email_subject, $email_message, $headers) ? "
":"
We're sorry, something went wrong.
Please return to .
");
$ip=$_SERVER['REMOTE_ADDR'];
$email_to = $_POST["email"];
$email_subject = "Giveaways | ";
$email_message1 = "Welcome to !
Thank you for entering to win 200 dollars. Please check this email address later to see if your the lucky winner!
Sincerely,
";
//email headers
$headers = 'From: '.$_POST["email"]."\r\n".
'Reply-To: '.$_POST["email"]."\r\n" .
'X-Mailer: PHP/' . phpversion();
echo (mail($email_to, $email_subject, $email_message1, $headers) ? "":"");
exit();
// test input values for errors
$errors = array();
if(strlen($fname) < 2) {
if(!$fname) { $errors[] = "You must enter a name."; }
else { $errors[] = "Name must be at least 2 characters."; }
}
if(!$email) { $errors[] = "You must enter an email."; }
else if (!validEmail($email)) { $errors[] = "You must enter a valid email."; }
if($errors) {
// output errors to browser and die with a failure message
$errortext = "";
foreach($errors as $error) {
$errortext .= "
".$error."";
}
die("
The following errors occured:");
}
// check to see if email is valid
function validEmail($email) {
$isValid = true;
$atIndex = strrpos($email, "@");
if (is_bool($atIndex) && !$atIndex) { $isValid = false; }
else {
$domain = substr($email, $atIndex+1);
$local = substr($email, 0, $atIndex);
$localLen = strlen($local);
$domainLen = strlen($domain);
if ($localLen < 1 || $localLen > 64) { $isValid = false; } // local part length exceeded
else if ($domainLen < 1 || $domainLen > 255) { $isValid = false; } // domain part length exceeded
else if ($local[0] == '.' || $local[$localLen-1] == '.') { $isValid = false; } // local part starts or ends with '.'
else if (preg_match('/\\.\\./', $local)) { $isValid = false; } // local part has two consecutive dots
else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) { $isValid = false; } // character not valid in domain part
else if (preg_match('/\\.\\./', $domain)) { $isValid = false; } // domain part has two consecutive dots
else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local))) {
// character not valid in local part unless local part is quoted
if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\","",$local))) { $isValid = false; }
}
if ($isValid && !(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A"))) { $isValid = false; } // domain not found in DNS
}
return $isValid;
}
?>
[/php]