EDIT: This is different from the possible duplicate, as they never got the email. Mine sends randomly.
The code below has been working fine for almost a year. For about the past week, however, it only sends when it wants to. My guys use it at multiple locations on multiple devices, and the same thing is happeneing.
There's an html form that submits to this php code, which then emails me and displays an html confirmation page. They're getting the confirmation page, but I'm not getting the email. Later in the day, if I hit back, then submit again, I do get the email.
I can't figure it out. Any suggestions as to what's happening? I'm considering making a SQL database that it submits to first, so that I can look up what they entered incase I don't get the email.
Thanks!
<?php
if(isset($_POST['submit'])) {
$to = "email_removed@gmail.com";
$subject = "Daily Inventory Submission";
// data the visitor provided
$location_field = filter_var($_POST['location'], FILTER_SANITIZE_STRING);
$yourname_field = filter_var($_POST['yourname'], FILTER_SANITIZE_STRING);
$biscuitsfull_field = filter_var($_POST['biscuits_full'], FILTER_SANITIZE_STRING);
$biscuitspartial_field = filter_var($_POST['biscuits_partial'], FILTER_SANITIZE_STRING);
$biscuitsemergency_field = filter_var($_POST['biscuits_emergency'], FILTER_SANITIZE_STRING);
$gravyfull_field = filter_var($_POST['gravy_full'], FILTER_SANITIZE_STRING);
$gravypartial_field = filter_var($_POST['gravy_partial'], FILTER_SANITIZE_STRING);
$eggsfull_field = filter_var($_POST['eggs_fullflats'], FILTER_SANITIZE_STRING);
$eggspartial_field = filter_var($_POST['eggs_partial'], FILTER_SANITIZE_STRING);
$cheese_field = filter_var($_POST['cheese'], FILTER_SANITIZE_STRING);
$sausagefull_field = filter_var($_POST['sausage_full'], FILTER_SANITIZE_STRING);
$sausagepartial_field = filter_var($_POST['sausage_partial'], FILTER_SANITIZE_STRING);
$jalapenos_field = filter_var($_POST['jalapenos'], FILTER_SANITIZE_STRING);
$sprayoil_field = filter_var($_POST['spray_oil_cans'], FILTER_SANITIZE_STRING);
$pouroil_field = filter_var($_POST['pour_oil'], FILTER_SANITIZE_STRING);
$tofu_field = filter_var($_POST['tofu'], FILTER_SANITIZE_STRING);
$almondmilk_field = filter_var($_POST['almond_milk'], FILTER_SANITIZE_STRING);
$veganbutter_field = filter_var($_POST['vegan_butter'], FILTER_SANITIZE_STRING);
$realbutter_field = filter_var($_POST['real_butter'], FILTER_SANITIZE_STRING);
$bacon_field = filter_var($_POST['bacon'], FILTER_SANITIZE_STRING);
$togo_field = filter_var($_POST['to_go'], FILTER_SANITIZE_STRING);
$hereboats_field = filter_var($_POST['here_boats'], FILTER_SANITIZE_STRING);
$flour_field = filter_var($_POST['flour'], FILTER_SANITIZE_STRING);
$potatoes_field = filter_var($_POST['potatoes'], FILTER_SANITIZE_STRING);
$waters_field = filter_var($_POST['waters'], FILTER_SANITIZE_STRING);
$oj_field = filter_var($_POST['orange_juice'], FILTER_SANITIZE_STRING);
$topo_field = filter_var($_POST['topo'], FILTER_SANITIZE_STRING);
$cokes_field = filter_var($_POST['cokes'], FILTER_SANITIZE_STRING);
$comment = filter_var($_POST['comment'], FILTER_SANITIZE_STRING);
//constructing the message
$body = "
Location: $location_field\n
Employee: $yourname_field\n\n
Biscuits_FULL: $biscuitsfull_field\n
Biscuits_Partial: $biscuitspartial_field\n
Biscuits_Emergency: $biscuitsemergency_field\n\n
Gravy_Full: $gravyfull_field\n
Gravy_Partial: $gravypartial_field\n\n
Eggs_Full: $eggsfull_field\n
Eggs_Partial: $eggspartial_field\n\n
Cheese: $cheese_field\n\n
Sausage_Full: $sausagefull_field\n
Sausage_Partial: $sausagepartial_field\n\n
Jalapenos: $jalapenos_field\n\n
Spray Oil Cans: $sprayoil_field\n
Pour Oil : $pouroil_field\n\n
Tofu: $tofu_field\n
Almond Milk: $almondmilk_field\n
Vegan Butter: $veganbutter_field\n\n
Real Butter: $realbutter_field\n\n
Bacon: $bacon_field\n\n
To Go Boxes: $togo_field\n
Here Boats: $hereboats_field\n\n
Flour: $flour_field\n
Potatoes: $potatoes_field\n\n
Waters: $waters_field\n
Daiya: $oj_field\n
Topos: $topo_field\n
Cokes: $cokes_field\n\n
Message:\n\n $comment";
mail($to, $subject, $body);
// redirect to confirmation
header('Location: confirmation.htm');
} else {
echo "Error, not sent";}
?>