Hi, I’ve been trying to set up an online ordering platform for my school’s coffee shop where hitting the submit button will automatically send an email including their order information to the cafe’s address. My code seems to go through the PHP file, as when you click submit, a php url appears for a second before it loads the success page, but no email is being sent…
My HTML Button:
[php]
Order Now
×
Name
Small
Regular
Pick-up Time:
7:30
7:35
7:40
7:45
7:50
7:55
8:00
4th Period (ASAP)
5th Period (ASAP)
Place Order
and my PHP component:
[php]<?php
if(isset($_POST[‘email’])) {
$email_to = "[email protected]";
$email_subject = “Email subject”;
$name = $_POST[‘name’]; // required
$email_from = $_POST[‘email’]; // required
$size = $_POST[‘size’]; // required
$time = $_POST[‘time’]; // required
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message = "Form details below.\n\n";
$email_message .= "Name: ".clean_string($name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Size: ".clean_string($size)."\n";
$email_message .= "Time: ".clean_string($time)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
‘X-Mailer: PHP/’ . phpversion();
mail($email_to, $email_subject, $email_message, $headers);
?>