dongying3744 2016-05-30 20:46
浏览 61

PHP表单电子邮件提交每次都不起作用

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
 
Employee: $yourname_field

 

Biscuits_FULL:      $biscuitsfull_field

Biscuits_Partial:   $biscuitspartial_field

Biscuits_Emergency: $biscuitsemergency_field



Gravy_Full:    $gravyfull_field

Gravy_Partial: $gravypartial_field



Eggs_Full:    $eggsfull_field

Eggs_Partial: $eggspartial_field



Cheese:  $cheese_field



Sausage_Full:    $sausagefull_field

Sausage_Partial: $sausagepartial_field



Jalapenos:  $jalapenos_field



Spray Oil Cans:  $sprayoil_field

Pour Oil :       $pouroil_field



Tofu:         $tofu_field

Almond Milk:  $almondmilk_field

Vegan Butter: $veganbutter_field



Real Butter: $realbutter_field



Bacon: $bacon_field



To Go Boxes:  $togo_field

Here Boats:   $hereboats_field



Flour:    $flour_field

Potatoes: $potatoes_field



Waters:        $waters_field

Daiya:         $oj_field

Topos:         $topo_field

Cokes:         $cokes_field








Message:

 $comment";

mail($to, $subject, $body);

// redirect to confirmation
header('Location: confirmation.htm');
} else {
echo "Error, not sent";}
?>
  • 写回答

1条回答 默认 最新

  • dpxbc88022 2016-05-30 20:53
    关注

    I would suggest using a class specifically designed for this purpose instead of using the raw mail function, look up https://github.com/PHPMailer/PHPMailer.

    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100