2016-09-26 39 views
-2

任何人都可以幫助我!這個PHP並不在我的網站工作,不發送電子郵件,如果我改變模具(錯誤),頁面對我說的.. enter image description herePHP表單聯繫人,帶有複選框,錯誤500

有去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 = "[email protected]"; 
$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; 
?> 
+4

500錯誤=服務器錯誤(可能是一些PHP錯誤)。檢查你的錯誤日誌或打開顯示錯誤,你會得到一個適當的錯誤信息,你可以與我們分享。這裏你可以看到如何打開它:http://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display –

+3

順便說一句,你爲什麼要存儲所有的後變量值,然後直接使用post變量,稍後呢? –

回答

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

是的,這可能是(假設OP沒有遺漏這個) –

+0

我認爲他確實粘貼了整個代碼。 – Phiter

+0

我嚴重懷疑會導致http 500錯誤。 – jeroen