Forgive me if this is basic, but this is my first effort at using PHP.
Until recently, I had a working feedback form using PHP which used the code below. Then one day recently it stopped working. Even if someone puts in a valid email address and name, they get the ‘feedback failed’ webpage and no feedback is emailed to me. I haven’t changed anything (I’ve taken out the live email and web addresses from the code listing below for safety is all), so does anyone have an idea why has the form stopped working, please?
<?php
/* All form fields are loaded */
$to = “me[at]myemailaddresshere.com” ;
$subject = “Feedback”;
$from = $_REQUEST[‘email’] ;
$name = $_REQUEST[‘contactname’] ;
$headers = “From: $from”;
$fields = array();
$fields{“contactname”} = “Name”;
$fields{“email”} = “Email”;
$fields{“comments”} = “Comments”;
$body = "Feedback has been received:
“; foreach($fields as $a => $b){ $body .= sprintf(”%20s: %s
",$b,$_REQUEST[$a]); }
$headers2 = “From: noreply[at]myemailaddresshere.com”;
$subject2 = “Thank you for your feedback”;
$autoreply = “Thank you text goes here”;
if (!preg_match(“/\w+([-+.]\w+)@\w+([-.]\w+)\.\w+([-.]\w+)*/”, $email)) {
header( “Location: http://www.mywebsiteaddresshere.co.uk/feedbackformfail.shtml” );
}
elseif ($contactname == “”) {
header( “Location: http://www.mywebsiteaddresshere.co.uk/feedbackformfail.shtml” );
}
/* Sends the mail and opens the feedbackformsuccess page if the mail is successfully sent, or the error page otherwise. */
elseif (mail($to, $subject, $body, $headers) /&& mail($from, $subject2, $autoreply, $headers2)/) {
header( “Location: http://www.mywebsiteaddresshere.co.uk/feedbackformsuccess.shtml” );
}
else {
header( “Location: http://www.mywebsiteaddresshere.co.uk/feedbackformfail.shtml” );
}
?>
Thanks.