我有一個提交給它的自我在這裏HTML表單是HTML表單PHP的形式提交給本身不工作
<div class="col-md-6 contact-grid">
<form name="submitted" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="POST">
<div class="styled-input wow slideInUp animated animated" data-wow-delay=".5s">
<input type="text" id="name" required />
<label>Name</label>
<span></span> </div>
<div class="styled-input wow slideInUp animated animated" data-wow-delay=".5s">
<input type="email" id="email" required />
<label>Email</label>
<span></span> </div>
<div class="styled-input wow slideInUp animated animated" data-wow-delay=".5s">
<input type="tel" id="phone" required />
<label>Phone</label>
<span></span> </div>
<div class="styled-input wide wow slideInUp animated animated" data-wow-delay=".5s">
<textarea id="message" required></textarea>
<label>Message</label>
<span></span> </div>
<div class="send wow shake animated animated" data-wow-delay=".5s">
<input name="submit" type="submit" value="Send">
</div>
</form>
</div>
,下面將我的PHP代碼來處理表單
<?php
session_start();
//error_reporting(0);
if(isset($_POST['submitted'])) {
$sendto = "[email protected]";
$usermail = strip_tags($_POST['email']);
$content = nl2br($_POST['message']);
$phone = strip_tags($_POST['phone']);
$name = strip_tags($_POST['name']);
$subject = "New Feedback Message";
$headers = "From: " . strip_tags($usermail) . "\r\n";
$headers .= "Reply-To: ". strip_tags($usermail) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html;charset=utf-8 \r\n";
$msg = "<html><body style='font-family:Arial,sans-serif;'>";
$msg .= "<h2 style='font-weight:bold;border-bottom:1px dotted #ccc;'>New User Feedback</h2>\r\n";
$msg .= "<p><strong>Sent by:</strong> ".$usermail."</p>\r\n";
$msg .= "<p><strong>Message:</strong> ".$content."</p>\r\n";
$msg .= "<p><strong>Name:</strong> ".$name."</p>\r\n";
$msg .= "<p><strong>Phone:</strong> ".$phone."</p>\r\n";
$msg .= "</body></html>";
if(mail($sendto, $subject, $msg, $headers)) {
$_SESSION['errormsg'] = "Mail Sent. Thank you we will contact you shortly.";
echo '<center><p style="color:green">' . $_SESSION['errormsg']. '</p></center>';
} else {
$_SESSION['errormsg'] = "Mail not Sent. Try Again.";
echo '<center><p style="color:red">' . $_SESSION['errormsg'].
'</p></center>';
}
}
?>
但我的問題是當提交表單沒有消息顯示,也沒有錯誤信息請任何幫助
還有什麼幫助嗎? – youngdero
請忽略我現在正在工作的第一條消息,在頁面上做了一次硬性刷新,然後我再次嘗試,並且它工作時豎起大拇指,但它在提交時顯示此提示:未定義索引:C:\ xampp \ htdocs \ dav2 \ contactform.php線路7 終於演出成功 公告:未定義的索引:在....消息 注意:未定義指數:手機.... 注意:未定義指數:名字....最後顯示成功消息 – youngdero
我知道我可以用// error_reporting(0)刪除錯誤;但我想修復它 – youngdero