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条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效