在我的聯繫形式的PHP似乎並沒有工作。我得到一個 「請更正以下錯誤:無法找到什麼是錯的在我的PHP的聯繫表格
寫下您的消息 點擊後退按鈕,然後再試一次」如果有經驗的人可以分享一些建議,我會非常感激。謝謝 !
<?php
/* Set e-mail recipient */
$myemail = "[email protected]";
/* Check all form inputs using check_input function */
$name = check_input($_POST['name'], "Enter your name");
$phone = check_input($_POST['phone'], "Enter phone number");
$email = check_input($_POST['email']);
$message = check_input($_POST['message'], "Write your message");
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("E-mail address not valid");
}
/* Let's prepare the message for the e-mail */
$message = "
Name: $name
E-mail: $email
Phone: $phone
Message:
$message
";
/* Send the message using mail() function */
mail($myemail, $phone, $message);
/* Redirect visitor to the thank you page */
header('Location: thanks.html');
exit();
/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<body>
<p>Please correct the following error:</p>
<strong><?php echo $myError; ?></strong>
<p>Hit the back button and try again</p>
</body>
</html>
<?php
exit();
}
?>
<div class="wrapper">
<div id="contact_form">
<form name="form1" id="ff" method="post" action="form.php">
<label>
<span>Name*:</span>
<input type="text" placeholder="Please enter your name" name="name" id="name" required autofocus>
</label>
<label>
<span>Phone:</span>
<input type="tel" placeholder="Please enter your phone" name="phone" id="phone">
</label>
<label>
<span>Email*:</span>
<input type="email" placeholder="[email protected]" name="email" id="email" required>
</label>
<label>
<span>Message:</span>
<textarea placeholder="message"></textarea>
</label>
<input class="sendButton" type="submit" name="Submit" value="Send">
</form>
</div>
</div>
請爲未來REFFERENCE,在發帖時刪除機密信息。 – Xorifelse
對不起,第一次在這裏沒有意識到。謝謝 – spum0n1