PHP表单联系人,带复选框,错误500

时间:2016-09-26 18:37:44

标签: php forms checkbox contact-form

任何人都可以帮助我!这个php在我的网站上不起作用,不发送电子邮件,如果我改变死(错误),页面对我说.. enter image description here

有de php动作

    <?php
$name = $_POST['name'];
$lastname = $_POST['lastname'];
$email = $_POST['mail'];
$Title = $_POST ['position/title'];
$company = $_POST ['company'];
$location = $_POST ['location'];
$telephone = $_POST['telephone'];
$services = $_POST['services'];
$string = join(" \r\n ", $services);
$timeframe = $_POST['timeframe'];
$comments = $_POST['comments'];
$learn = $_POST['learn'];
        $message = '<html><body>';
        $message .= '<img src="http://www.corbisglobal.com/assets/web/img/contact-CG-logo.png" />';
        $message .= '<table rules="all" style="border-color: #666; border : 1px;" cellpadding="10">';
        $message .= "<tr style='background: #ddd;'><td><strong>Name:</strong> </td><td>" . strip_tags($_POST['name']) .  "</td></tr>";
         $message .= "<tr style='background: #eee;'><td><strong>Lastname:</strong> </td><td>" . strip_tags($_POST['lastname']) . "</td></tr>";
        $message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($_POST['mail']) . "</td></tr>";
         $message .= "<tr><td><strong>Title/Position:</strong> </td><td>" . strip_tags($_POST['position/title']) . "</td></tr>";
        $message .= "<tr><td><strong>Company:</strong> </td><td>" . strip_tags($_POST['company']) . "</td></tr>";
        $message .= "<tr><td><strong>Location:</strong> </td><td>" . strip_tags($_POST['location']) . "</td></tr>";
         $message .= "<tr><td><strong>Services:</strong> </td><td>" . join(" \r\n, ", $services) . "</td></tr>";
         $message .= "<tr><td><strong>Timeframe:</strong> </td><td>" . strip_tags($_POST['timeframe']) . "</td></tr>";
         $message .= "<tr><td><strong>Learn about Corbis:</strong> </td><td>" . strip_tags($_POST['learn']) . "</td></tr>";
        $message .= "<tr><td><strong>Comments:</strong> </td><td>" . strip_tags($_POST['comments']) . "</td></tr>";
        $message .= "</table>";
        $message .= "</body></html>";
$recipient = "recipient@example.com";
$subject = "Contact Form from CorbisGlobal Web";
$mailheader .= "MIME-Version: 1.0\r\n";
$mailheader .= "From: " . strip_tags($_POST['mail']) . "\r\n";
$mailheader .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($recipient, $subject, $message, $mailheader) or die (error);
header("Location: thankyou.php"); 
exit; 
?>

1 个答案:

答案 0 :(得分:4)

您的错误可能在中间一行:

$subject = "Contact Form from CorbisGlobal Web";
$mailheader .= "MIME-Version: 1.0\r\n";
$mailheader .= "From: " . strip_tags($_POST['mail']) . "\r\n";

在您为其添加更多文字之前,您没有创建变量$mailheader

启用错误报告,您将获得有意义的错误消息,以帮助您解决大部分问题。

此外,您正在执行此操作:

mail($recipient, $subject, $message, $mailheader) or die (error);

or die (error),您可能没有定义error常量,并且在您向我们展示的代码中没有此名称的变量。要检查mail函数是否已接受您的输入,您可以执行以下操作:

if (mail($recipient, $subject, $message, $mailheader)){
    header("Location: thankyou.php"); 
}
else{
    die("Error sending email");
}