For some reason my forms have stopped working and I cannot get themt o send any emails. I have checked the server logs and I can see on form submition it throws the following error.
PHP Notice: Undefined variable: email_message on line 21,
<?php
if(!isset($_POST['submit']))
{
//This page should not be accessed directly. Need to submit the form.
echo "error; you need to submit the form!";
}
$name = $_POST['name'];
$department = $_POST['department'];
$question = $_POST['question'];
$email_to = 'me@me.com';
$email_from = 'me@me.com';
//possible html email??
$email_subject = "Principal Question\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "<b>Name:</b> ".clean_string($name)."\n<br>";
$email_message .= "<b>Department:</b> ".clean_string($department)."\n<br>";
$email_message .= "<b>Question:</b> ".clean_string($question)."\n<br>";
// create email headers
$headers = "Content-type: text/html\r\n";
$headers .= 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
@mail($email_from, $email_subject, $email_message, $headers);
?>
<?php
if( !empty( $_POST ) ) {
header( "Location: thankyou.html" ) ; exit ;
}
?>
Can anyone help?
Thanks