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

PHP form contact, with checkboxs, error 500

谁能帮帮我!这个 php 在我的网站上不起作用,不发送电子邮件,如果我更改死机(错误),页面对我说..

有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; 
?>

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

$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");
}