I have the following code as a file named contact.php which is to send an email to the designated email address but as it runs it appears acknowledge it has sent an email as "we have received your request but the email does not get sent to the designated email address.. Anyone know if there is a flaw in my code?
<?php
$to ="Your email address";
$subject = "Reservation";
$name = $_REQUEST['name'] ;
$phone = $_REQUEST['phone'] ;
$email = $_REQUEST['email'] ;
$day = $_REQUEST['day'] ;
$month = $_REQUEST['month'] ;
$year = $_REQUEST['year'] ;
$people = $_REQUEST['people'] ;
$comments = $_REQUEST['comments'] ;
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Name: $name \n";
$email_message .= "Phone: $phone \n";
$email_message .= "Email: $email \n";
$email_message .= "Date: $day $month $year \n";
$email_message .= "No. of People: $people \n";
$email_message .= "Comments: $comments \n";
$headers = "From: $email";
$sent = mail($to, $subject, $email_message, $headers) ;
if ($sent)
{
// Successful popup message, redirected back to view contacts
echo "<script type='text/javascript'>alert('We have received your Reservation Request'); window.location.href = 'reservation.html';</script>";
}
else
{
// Unsuccessful popup message, redirected back to view contacts
echo "<script type='text/javascript'>alert('There was an Error! Please try again.'); window.location.href = 'reservation.html';</script>";
}
?>