douer9399 2015-10-10 14:14
浏览 33

php mail()两个副本发送

I have a simple message that I send using php mail(). The code used:

//recipient info
$to = "$bookernavn <$mail>";
$from = "Visens Venner Hillerød <booking@eksample.dk>";
$subject = "Kvittering - $a_titel - ". date("j/n - Y",$a_dato);

$headers  = "MIME-Version: 1.0" . "
";
$headers .= "Content-type: text/html; charset=utf-8" . "
";
$headers .= "From: $from" . "
";
$headers .= "Reply-To: $from" . "
";
$headers .= "Return-Path: $from" . "
";
$headers .= "Bcc: $from" . "
";

// now lets send the email. 
mail($to, $subject, $mailmsg, $headers); }

For some strange reason two mails are sent each time...
Sometimes with several minutes in between...
Any ideas?

  • 写回答

2条回答 默认 最新

  • dsfphczao23473056 2015-10-10 14:31
    关注

    You don't check to see if the form has been submitted so a browser refresh will send the form data again and cause the mail to be sent again. This also happens when a user presses the back button.

    After the email is sent you need to do a 303 redirect to prevent the re-submission. You can redirect to the same page if you'd like.

    This is called the Post/Redirect/Get pattern.

    mail(...);
    header('Location: /some-page-php', true, 303);
    exit;
    
    评论

报告相同问题?

悬赏问题

  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败
  • ¥15 Centos7 / PETGEM
  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
  • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗
  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用