我的联系表格存在问题,希望有人可以提供帮助。当我点击“发送”时,它只是停留在'loadiing'。我能够在一个点发送,然后尝试获取电话号码,现在没有任何工作。据我所知,事情正指向正确的地方。我错过了什么?
www.krjwoodcraft
<?php
$name = $_POST['name'];
$mobile = $_POST['url'];
$subject = $_POST['subject'];
$sender = $_POST['email'];
$message= $_POST['message'].' <br>Mobile: '.$_POST['url'].' ';
$your_site_name = "www.krjwoodcraft.com";
$your_email = "rob.catharsis@gmail.com";
// setting header:
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset=utf-8\r\n";
$header .= "From: {$name} <{$sender}>\r\n";
// to subject message header
$result = mail($your_email, "Message from ".$your_site_name, nl2br($message), $header);
echo "Your Message has been sent";
?>
<!-- Contact Form -->
<div class="row">
<div class="span12">
<div class="trac_contactform">
<form id="contact_form" class="row" name="form1" method="post" action="send.php">
<div class="span6">
<input type="text" class="full" name="name" id="name" placeholder="Name" />
<div id="error_name" class="error">Please check your name</div>
</div>
<div class="span6">
<input type="text" class="full" name="email" id="email" placeholder="Email" />
<div id="error_email" class="error">Please check your email</div>
</div>
<div class="span6">
<input type="text" class="full" name="url" id="url" placeholder="Phone Number"/>
</div>
<div class="span6">
<input type="text" class="full" name="subject" id="subject" placeholder="Subject"/>
</div>
<div class="span12">
<textarea cols="10" rows="10" name="message" id="message" class="full" placeholder="Message"></textarea>
<div id="error_message" class="error">Please check your message</div>
<div id="mail_success" class="success">Thank you. Your message has been sent.</div>
<div id="mail_failed" class="error">Error, email not sent</div>
<p id="btnsubmit">
<input type="submit" id="send" value="Send Now" class="btn btn-large btn-primary btn-embossed" /></p>
</div>
</form>
</div>
</div>
</div>
答案 0 :(得分:0)
首先,我的神人这个网站缓慢加载:
如果在添加$mobile = $_POST['url'];
之前一切正常,可能是您未正确附加data
。
<input type="text" class="full" name="url" id="url" placeholder="Phone Number"/>
即便如此,使用url
作为ID
看起来有点奇怪。为什么不ID phone
?
500内部服务器错误是一种非常通用的HTTP状态代码 意味着网站的服务器上出现了问题但服务器出了问题 无法确切地说明具体问题是什么。
当我刷新页面时,表单完全停止工作。也许它与您的验证代码没有发送数据有关?
答案 1 :(得分:0)
尝试以下
在您的网页contact.js中,您有以下内容,非常适合GET但不适用于POST
data: "name=" + name + "&email=" + email + "&subject=" + "You Got Email" + "&message=" + message,
但是jquery正在寻找像以下
这样的对象形式data: {name: name, email: email, subject: "You Got Email", message: message},
修改强>
同样在您的js中,您只收集name
,email
,subject
和message
。您没有收集url
,而在您的send.php中,它正在寻找name
,email
,subject
,message
和url
以及你没有检查它们是否被发送并且php可能会抛出错误:… index url not found in …
您应该始终检查是否正在发送POST / GET项目并不总是假设它们是一直发送的。
if(isset($_POST['name'], $_POST['email'], $_POST['subject'], $_POST['message'], $_POST['url'])){
#your email stuff
}
JS:
var email = $("#email").val();//add this at the top of your $("#send").click(function(){
data: {name: name, email: email, subject: "You Got Email", message: message, url: email},//and add url parameter