尝试编写联系表单脚本时,我的后续页面不处理...
<?php
$rpname = $_POST['name'];
$rpnumber = $_POST['phone'];
echo $rpname;
echo $rpnumber;
$rpname = $_POST['name'];
$rpnumber = $_POST['phone'];
$to = "liam@.co.uk"; // CHANGE THIS TO EMAIL YOU WANT
$subject = "Phonecall Request"
//begin of HTML message
$message = "
Phone call request -
From : $rpname,
Number: $rpnumber
";
$headers = "MIME-Version: 1.0rn";
$headers .= "Content-type: text/html; charset=iso-8859-1rn";
$headers .= "From: Website Enquiry";
if (isset($rpname))
{
// now lets send the email.
mail($to, $subject, $message, $headers);
$page='index.html';
header('Location:'.$page);
header('Location: ' . $_SERVER['HTTP_REFERER'] . '?e=Message Sent!');
} ?>
我试图回应顶部的变量,但我得到一个没有来源的空白页......
答案 0 :(得分:3)
$subject = "Phonecall Request"
后需要分号(;)。
如果您的配置启用了错误报告,您自己会发现此错误。这是在php.ini
文件中。这很可能位于/etc/php5/cgi/
。添加以下行:
display_errors = On
error_reporting = E_ALL
如果您无法在服务器上访问此文件,则可以在每个文档的基础上添加它,方法是在每个PHP文档的开头包含以下行:
ini_set('display_errors', '1');
error_reporting(E_ALL);
答案 1 :(得分:0)
我认为你在这行上有一个副本错误:
$headers = "MIME-Version: 1.0rn";
$headers .= "Content-type: text/html; charset=iso-8859-1rn";
$headers .= "From: Website Enquiry";
它应该是这样的:
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: Website Enquiry";
rn
没有任何意义,你想要\r\n
这是一个换行符。