开发者

Error implementing AJAX/PHP/HTML5 form

开发者 https://www.devze.com 2023-03-28 10:19 出处:网络
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 n

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 = “test@email.com”;
$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.


I am pretty sure you copied the code with those ugly double quotes (MSWord quotes), you should chage to "

try

<?php
    $sender = $email;
    $receiver = "test@email.com";
    $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.";
    }
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消