实现 AJAX/PHP/HTML5 表单时出错

发布于 2024-11-30 03:14:48 字数 764 浏览 1 评论 0原文

我正在尝试在这里解决这个难题。此页面上的联系表单 (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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妳是的陽光 2024-12-07 03:14:48

我很确定您复制的代码带有那些丑陋的双引号(MSWord引号),您应该更改为

尝试

<?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 am pretty sure you copied the code with those ugly double quotes (MSWord quotes), you should chage to "

try

<?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.";
    }
?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文