2017-05-29 102 views
-1

這裏是我的HTML和PHP代碼,當我提交表單數據時,它將我定位到沒有錯誤報告的空白窗口,既沒有將數據發送到郵件,要進一步注意我的PHP顯示錯誤和顯示啓動錯誤。雖然提交表單數據php腳本顯示空白頁面

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='[email protected]'; 
      $subject='Form Submission'; 
      $message="Name :".$name."\n"."Phone :".$phone."\n"."Wrote the following :"."\n\n".$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!"; 
      } 
      } 
      ?> 
+0

添加**的var_dump($ _ POST)**,看看有什麼被髮送到服務器 – user2182349

+0

按鈕添加name屬性'name = '提交' ' –

回答

0

而不是

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

使用

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

注意添加name="submit"

+0

謝謝你的回答:) –

0

按鈕輸入添加name="submit"

+0

謝謝你的回答:) –

+0

不要忘記upvote ...不客氣 – Joseph