duanlei1957 2018-07-30 22:52
浏览 98

PHP重新提交和订阅数据问题

I'm facing two issue with the following code.

  1. I'm using the following code to submit the subscriber's email address to my email address the code is working and email is also being sent but the issue is that I can't see subscriber's email address.
  2. Every time when I refresh the page it shows an alert box saying resubmission confirmation and when I properly refresh the page by closing the alert box or pressing ok then it shows the success message that was showing while the subscriber submit his/her email.

The code is below :

     <?php

                if(isset($_POST['submit'])){
                  $email=$_POST['email'];

                  //send mail 
                 $to='info@soapbox.media';
                 $subject='New Subscriber';
                 $body='<html>
                 <body>
                 <h3>Feedback</h3>
                 <hr>

                 <p> Email :<br/>'.$email.'</p>

                 </body>

                 </html>';

                 $headers  ="From:<".$email.">
";
                 $headers .="reply-To:".$email."
";
                 $headers .="NINE-Version: 1.0
";
                 $headers .="Content-type: text/html; charset=utf-8";

              //confirmation mail
                         $user=$email;
                         $usersubject = "SoapBox";
                         $userheaders = "From:  info@soapbox.media
";
                         $usermessage = "Thank you for subscribing SoapBox.";


                        //sending process
                         $send=mail($to, $subject, $body, $headers);
                         $confirm=mail($user, $usersubject, $userheaders,$usermessage );

                         if($send && $confirm){
                          echo "<div class='alert alert-success alert-dismissible fade show'>
                            <button type='button' class='close' data-dismiss='alert'>&times;</button>
                            <strong>Success!</strong> You have subscribed successfully.
                          </div>";    
                         }

                         else{
                          echo "Failed";
                         }

                        }




?>               
  • 写回答

1条回答

  • 普通网友 2018-07-31 19:08
    关注
    1. $confirm=mail($user, $usersubject, $usermessage, $userheaders); by @Funk Forty Niner

    2. place a header('location: ' . $_SERVER['PHP_SELF']); after you've sent the mail - you will get rid of the post-header, so no more popup after F5 - You will get rid of your confirmation msg aswell so you could add a GET parameter to your URL to show the confirmation message.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题