1
我有一個使用AJAX提交表單和PHP的聯繫表單字段。聯繫表格返回錯誤,特別是'email'字段
我有一個小問題。我不斷收到一個錯誤,指出「the request was successful, but the form was not filled out correctly.
」這適用於'email
'字段。表單未提交,用戶必須填寫表單。
不知何故,輸入的任何電子郵件地址無效。
有誰知道這是爲什麼?
/* Email Variables */
$emailSubject = 'You have received an inquiry from your website';
$webMaster = '[email protected]';
/* Data Variables */
$first = Trim(stripslashes($_POST['First']));
$last = Trim(stripslashes($_POST['Last']));
$email = Trim(stripslashes($_POST['E-Mail']));
$message = Trim(stripslashes($_POST['Message']));
$tempt = $_POST['tempt'];
$tempt2 = $_POST['tempt2'];
if ($tempt == 'http://' && empty($tempt2)) {
$error_message = '';
$reg_exp = "/^[a-zA-Z0-9._%+-][email protected][a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$/";
if(!preg_match($reg_exp, $email)) {
$error_message .= "<p>A valid email address is required.</p>";
}
if (empty($first)) {
$error_message .= "<p>Please provide your first name.</p>";
}
if (empty($last)) {
$error_message .= "<p>Please provide your last name.</p>";
}
if (empty($message)) {
$error_message .= "<p>Comments box cannot be left empty.</p>";
}
if (!empty($error_message)) {
$return['error'] = true;
$return['msg'] = "<h3> The request was successful, but the form is not filled out correctly.</h3>".$error_message;
echo json_encode($return);
exit();
} else {
$return['error'] = false;
$return['msg'] = "<p>Thank you for contacting us. We definitely value your feedback," .$first .".</p>";
echo json_encode($return);
}
} else {
$return['error'] = true;
$return['msg'] = "<h3>There was a problem while sending this form. Try it again.</h3>";
echo json_encode($return);
}
HTML
<form class="contact-me" action="mail/mailform.php" method="post" name="contact-me">
<div id="response"><!-----------------CONTAINS FORM ERROR MESSAGE--------------></div>
<input name="First" class="required" title="Your First Name is Required" id="first" autofocus placeholder="First Name" type="text" maxlength="15"></input><br>
<input name="Last" title="Your Last Name is Required" id="last" placeholder="Last Name" type="text" maxlength="15"></input><br>
<input name="E-mail" title="E-Mail Address is Required" id="email" placeholder="Email Address" type="email" maxlength="50"></input><br>
<textarea name="Message" title="Comments are Required" placeholder="Comments" rows="1" cols="50" id="message" onKeyDown="textCounter(this.form.comments,this.form.countDisplay);"onKeyUp="textCounter(this.form.message,this.form.countDisplay);"></textarea><br>
<input type="hidden" name="tempt" id="tempt" value="http://" />
<input type="hidden" name="tempt2" id="tempt2" class="clear" value="" />
<input name="countDisplay" type="text" id="countdisplay" value="2000" size="4" maxlength="4" readonly></input><br>
<button class="button" ontouchstart="('touchstart');">SEND</button>
</form>
你願意分享的就是這個所謂的什麼框架是信息?或者什麼具體的頁面給你這個'錯誤陳述'? – Smuuf
此錯誤發生在我創建的聯繫人頁面上。 www.3elementsreview.com/contact –
你爲什麼這麼確定這是給這個麻煩的電子郵件?也許還會顯示HTML表單? – putvande