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

报告相同问题?

悬赏问题

  • ¥50 使用CUDA如何高效的做并行化处理,是否可以多个分段同时进行匹配计算处理?目前数据传输速度有些慢,如何提高速度,使用gdrcopy是否可行?请给出具体意见。
  • ¥15 基于STM32,电机驱动模块为L298N,四路运放电磁传感器,三轮智能小车电磁组电磁循迹(两个电机,一个万向轮),如何通过环岛的原理及完整代码
  • ¥20 机器学习或深度学习问题?困扰了我一个世纪,晚来天欲雪,能饮一杯无?
  • ¥15 c语言数据结构高铁订票系统
  • ¥15 关于wkernell.PDB加载的问题,如何解决?(语言-c#|开发工具-vscode)
  • ¥15 (标签-STM32|关键词-智能小车)
  • ¥20 关于#stm32#的问题,请各位专家解答!
  • ¥15 (标签-python)
  • ¥20 搭建awx,试了很多版本都有错
  • ¥15 java corba的客户端该如何指定使用本地某个固定IP去连接服务端?