简体   繁体   English

PhP联系人表单显示空白页

[英]PhP Contact form shows a blank page

    <?php
if( isset($_POST['name']) )
{
    $to = 'email@email.com';

    $subject = $_POST['subject'];
    $message = $_POST['message'] . "\n\n" . 'Regards, ' . $_POST['name'] . '.';
    $headers = 'From: ' . $_POST['name'] . "\r\n" . 'Reply-To: ' . $_POST['email'] . "\r\n" . 'X-Mailer: PHP/' . phpversion();

    mail($to, $subject, $message, $headers);

    if( $_POST['copy'] == 'on' )
    {
        mail($_POST['email@email.com'], $subject, $message, $headers);
    }
}
?>

When i click "SEND" on my contact form it goes to a blank page, however I do recieve the email. 当我在联系表单上单击“发送”时,它将转到空白页,但是我确实收到了电子邮件。 What's wrong? 怎么了?

Thanks a lot. 非常感谢。

Carl 卡尔

Website 网站

http://www.vrijeme-reklame.net http://www.vrijeme-reklame.net

Contact form blank page 联系表格空白页

http://www.vrijeme-reklame.net/demo-contacts.php http://www.vrijeme-reklame.net/demo-contacts.php

Error message: 错误信息:

[Wed Mar 16 15:58:34.846118 2016] [lsapi:error] [pid 220778] [client 94.253.149.34:56523] mod_lsapi: [host www.vrijeme-reklame.net] [req POST /demo-contacts.php HTTP/1.1]: Could not stat script filename (/home/vrijemer/public_html/demo-contacts.php): errno 2, referer: http://www.vrijeme-reklame.net/ [2016年3月16日星期三15:58:34.846118] [lsapi:error] [pid 220778] [客户端94.253.149.34:56523] mod_lsapi:[主机www.vrijeme-reklame.net] [要求POST /demo-contacts.php HTTP /1.1]:无法统计脚本文件名(/home/vrijemer/public_html/demo-contacts.php):errno 2,引用者: http ://www.vrijeme-reklame.net/

The problem is your demo-contact.php does not print anything. 问题是您的demo-contact.php不打印任何内容。 Try adding some echo statement and it will not show blank page.instead it will print those echo statement. 尝试添加一些echo语句,它不会显示空白页面,而是会打印这些echo语句。

Other thing , you can do is , Try to redirect to some specified url whenever you want. 您可以做的另一件事是,随时尝试重定向到某些指定的url。 header('Location: http://www.vrijeme-reklame.net/#contact');

Your html page redirects to this php page, which then handles your data according to the code you have written, however, php code is not displayed on the page directly, similarly to javascript. 您的html页面重定向到该php页面,然后根据您编写的代码处理数据,但是,类似于javascript,php代码不会直接显示在页面上。 If you would like this page to display information, use echo in your php, or create html tags and put html in those. 如果您希望此页面显示信息,请在PHP中使用echo,或创建html标记并将html放入其中。 Alternatively, if you wished to not redirect to this page, and simply allow your php page to handle the code while remaining on the page with the form, google and us jquery and $.ajax 另外,如果您不希望重定向到此页面,而只允许您的php页面处理代码,而同时保留在表单中,则为google and us jquery和$ .ajax

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM