douying2243 2017-05-29 03:18
浏览 83
已采纳

提交表单数据时,php脚本显示空白页面[重复]

Here is my html and PHP code, when I submit the form data, it targets me to the blank window where no errors are been reported neither the data is been sent to the mail, to be further noted my PHP display error and display startup errors are on.

HTML

 <!-- form start  -->
        <form action="mail_handler.php" method="post" name="form" class="form-box">


         <div class="col-sm-6">
          <div class="form-group">

           <input type="text" name="name" class="form-control" placeholder="Your Name">
         </div>
       </div>

       <div class="col-sm-6">
         <div class="form-group">
           <input type="email" name="email" class="form-control" placeholder="Your Email">
         </div>
       </div>

       <div class="col-sm-6">
        <div class="form-group">
          <input type="tel" name="phone" class="form-control" placeholder="Your Phone Number">
        </div>

        <div class="col-sm-12">
         <div class="textarea-message form-group">
           <textarea name="msg" class="textarea-message form-control" placeholder="Your Message" rows="5">

           </textarea>
         </div>
       </div>


       <div class="text-center">      
        <button type="submit" class="load-more-button">submit
        </button>
      </div>

    </form>

PHP

    <?php
            if(isset($_POST['submit']))
            {
            $name=$_POST['name'];
            $email=$_POST['email'];
            $phone=$_POST['phone'];
            $msg=$_POST['msg'];

            $to='xyz@gmail.com'; 
            $subject='Form Submission';
            $message="Name :".$name."
"."Phone :".$phone."
"."Wrote the following :"."

".$msg;
            $headers="From: ".$email;

            if(mail($to, $subject, $message, $headers))
            {
            echo "<h1>Sent Successfully! Thank you"." ".$name.", We will contact you shortly!</h1>";
            }
            else
            {
            echo "Something went wrong!";
            }
            }
            ?>
</div>

展开全部

  • 写回答

2条回答 默认 最新

  • dsa1234569 2017-05-29 03:23
    关注

    Instead of

    <button type="submit" class="load-more-button">submit
    </button>
    

    Use

    <button type="submit" name="submit" class="load-more-button">submit
    </button>
    

    Note the added name="submit"

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部