2015-03-25 73 views
0

我想知道如何通過頁面確認它已被填充。PHP表單提交後消失

這就是我所得到的。

<?php 
if(!isset($_POST['submit'])) 
{echo 
     '<form action="" method="post"> 
      <input type="text" placeholder="From" name="from"><br> 
      <input type="text" placeholder="Subject" name="sub"><br> 
      <input type="text" placeholder="Message"name="mess"><br> 
      <input type="submit"> 
     </form>';} 
else{ 
$to = '[email protected], '. $from=$_POST['from']; 
$subject = $_POST['sub']; 
$message = $_POST['mess']; 

mail ($to , $subject , $message); 
    echo 'thanks for submitting!<br>';} 

?> 
+1

發生了什麼,你期望發生什麼? – Jite 2015-03-25 05:34:17

+0

此代碼...我的眼睛... – 2015-03-25 05:34:58

+0

我想要做的是在某人填寫表單以使表單消失並告訴他們「感謝提交!」之後 – SergeProtector 2015-03-25 16:35:20

回答

0

替換下面的代碼:

mail ($to , $subject , $message); 
    echo 'thanks for submitting!<br>'; 

通過這樣的:

if(@mail($to, $subject, $message)) { 
    echo "thanks for submitting"; 
}else{ 
    echo "Unable to submit your email."; 
} 

欲瞭解更多信息:http://php.net/manual/en/function.mail.php
祝你好運!