Hi guys,
I have a real issue .....! I am not bad with PHP but am much better at editing scripts that writing them .... this has got me stumped!
I have been using the same PHP Form2Email script for a few years now. I have used it on many websites and modified it in many ways and it has never given me a problem. It is very simple to handle and edit.
Suddenly - a few days ago - the script on my website stopped working. The form was sending and displaying the "Thank You" message but no emails were being received by the client or by me. I checked the form on 8 different servers / hosting companies and am getting the same result.
I just cannot for the life of me work out why an untouched piece of PHP code which was working fine - can suddenly stop working?! I will list the code below and pray that one of you will be able to see the problem? If anyone can answer why a piece of code can magically stop working that would be great!
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<?php
function treat_submission()
{
$user = $_POST['first'];
$email = $_POST['email'];
$last = $_POST['last'];
$phone = $_POST['phone'];
$comments = $_POST['comments'];
$my_email = "myemail@mydomain.com";
// MESSAGE TO ADMIN:
$headers = "To: ".$my_email. "\r\n";
$headers .= "From: ".$email. "\r\n";
$subject = "Form submitted via my website";
$msg = "".$user." ".$last." has submitted a form via the my website\r\n\r\n";
$msg.= "Email - ".$email."\r\n\r\n";
$msg.= "Phone - ".$phone."\r\n\r\n";
$msg.= "Comments - ".$comments."\r\n\r\n";
mail($my_email, $subject, $msg, $headers);
// MESSAGE TO VISITOR:
$headers = "To: ".$email. "\r\n";
$headers .= "From: ".$my_email. "\r\n";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$subject = "Thank you for your interest in my website.";
$msg = "
<html>
<head>
<title>Thank You! </title>
</head>
<body>
<p>This is an automated response from me.
<br><br>
Your details have been forwarded to me blah blah blah.
<br><br>
We plan to be back to you quickly, but certainly within 24 hours during normal circumstances.
<br><br>
Kind Regards,
<br><br>
Me
</p>
</body>
</html>
";
mail($email,$subject,$msg,$headers);
}
?>
</head>
<body>
<?php
if (isset($_POST['submit']))
echo (treat_submission($_POST));
else
echo ("<p align=\"center\">The form has not been received.</p>");
?>
<div>
<center>
<p><b>Thank you <?php print stripslashes($_REQUEST['first']); ?></b>
<br>
</p>
<p>Your request has been submitted to me.</p>
<p>We will respond as soon as possible. </p>
<p><a href="http://www.mywebsite.com">Click here to return to our home page</a></p>
<p> </p>
</center>
</div>
</body>
</html>
If any of you can help that would be amazing - this is majorly ruining my day! lol