這裏我用了兩個文件contact_us.php & mail.php聯繫我們形成不正常工作使用PHP
其不提供任何錯誤,但沒有得到郵件,請大家幫我任何事情錯在下面的代碼。
contact_us.php
<!DOCTYPE HTML>
<html>
<head>
<title>TPC</title>
<meta name="description" content="website description" />
<meta name="keywords" content="website keywords, website keywords" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="style/style.css" title="style" />
</head>
<body>
<form action="mail.php" method="post">
Name: <input class="contact" type="text" name="your_name" value="" /><br><br>
Email Address: <input class="contact" type="text" name="your_email" value="" /><br><br>
Message: <textarea class="contact textarea" rows="8" cols="50" name="your_enquiry"></textarea><br><br>
<p style="padding-top: 15px"><span> </span><input class="submit" type="submit" name="submit" value="submit" /></p>
</form>
</body>
</html>
mail.php
<?php
if(isset($_POST['submit'], $_POST['name'], $_POST['email'], $_POST['message'], $_POST['recipient'], $_POST['subject'], $_POST['formcontent'], $_POST['mailheader'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
$recipient = "[email protected]";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
};
echo "Thank You!";
?>
打開錯誤報告以找出腳本無法正常工作的原因。 '的error_reporting(E_ALL);' –
感謝@Burhan但我在哪裏可以找到option.canü請解釋更簡單地 –
你的條件是不正確的,因爲'$ _ POST [ 'mailheader']'和'$ _ POST [ 'formcontent' ''不存在。 –