实现 AJAX/PHP/HTML5 表单时出错
我正在尝试在这里解决这个难题。此页面上的联系表单 (http://www.b3studios.co.uk/) 使用 AJAX和PHP。我复制了所有代码并尝试使其工作(逆向工程 PHP)。我不确定 PHP 文件应该如何处理 AJAX 给出的数据。我尝试了以下 PHP 文件:
<?php
$sender = $email;
$receiver = “[email protected]”;
$email_body = “Name: $name \nEmail: $email \nMessage: $message”;
if( mail( $receiver, $subject, $email_body, “From: $sender\r\n” .
“Reply-To: $sender \r\n” . “X-Mailer: PHP/” . phpversion()) )
{
echo “Success! Your message has been sent. Thank You.”;
}
else
{
echo “Your message cannot be sent.”;
}
?>
按“发送消息”后,它卡在正在发送消息...... 任何解决问题的建议将不胜感激。
I'm trying to solve this puzzle here. The contact form on this page (http://www.b3studios.co.uk/) uses AJAX and PHP. I copied all the code and trying to make it work (reverse engineering PHP). I'm not sure how the PHP file should look like to handle the data given by AJAX. I tried the following PHP file:
<?php
$sender = $email;
$receiver = “[email protected]”;
$email_body = “Name: $name \nEmail: $email \nMessage: $message”;
if( mail( $receiver, $subject, $email_body, “From: $sender\r\n” .
“Reply-To: $sender \r\n” . “X-Mailer: PHP/” . phpversion()) )
{
echo “Success! Your message has been sent. Thank You.”;
}
else
{
echo “Your message cannot be sent.”;
}
?>
After pressing "Send Message" it gets stuck at sending message....
Any suggestions to troubleshoot would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我很确定您复制的代码带有那些丑陋的双引号
“
(MSWord引号),您应该更改为”
尝试
I am pretty sure you copied the code with those ugly double quotes
“
(MSWord quotes), you should chage to"
try