douying2243 2017-05-29 11:18
浏览 82
已采纳

提交表单数据时,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 11: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条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分