2013-03-02 88 views
0

我已經按照發送聯繫表格的簡單教程,但它似乎不工作。請有人協助請。下面發送聯繫表格不工作

形式:

<table width="400" border="0" cellspacing="1" cellpadding="0" align="center"> 
    <tbody> 
     <tr> 
      <td> 
       <form action="send.php" method="post" name="form1"> 
        <table width="100%" border="0" cellspacing="1" cellpadding="3"> 
         <tbody> 
          <tr> 
           <td width="16%">Name</td> 
           <td width="2%">:</td> 
           <td width="82%"><input id="Name" type="text" name="Name" size="50" /></td> 
          </tr> 
          <tr> 
           <td>Email</td> 
           <td>:</td> 
           <td><input id="customer_mail" type="text" name="customer_mail" size="50" /></td> 
          </tr> 
          <tr> 
           <td>Subject</td> 
           <td>:</td> 
           <td><input id="Subject" type="text" name="Subject" size="50" /></td> 
          </tr> 
          <tr> 
           <td>Detail</td> 
           <td>:</td> 
           <td><textarea id="detail" cols="50" name="detail" rows="4"></textarea></td> 
          </tr> 
          <tr> 
           <td></td> 
           <td></td> 
           <td><input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td> 
          </tr> 
         </tbody> 
        </table> 
       </form> 
      </td> 
     </tr> 
    </tbody> 
</table> 

這裏是我的PHP:

<?php 
    $to ='[email protected]'; 

    $header="from: $name <$mail_from>"; 

    $mail_from="$customer_mail"; 
    $Subject="$Subject"; 
    $detail="$detail"; 

    $send_contact=mail($to,$header,$Subject,$detail); 

    if($send_contact){ 
     echo "We've recived your contact information"; 
    } else { 
     echo "ERROR"; 
    } 
?> 

這是錯誤:

服務器錯誤而檢索http://nqmedia.co.uk/send_contact.php 該網站遇到錯誤。它可能因維護而關閉或配置不正確。 以下是一些建議: 稍後重新加載此網頁。 HTTP錯誤500(內部服務器錯誤):服務器試圖完成請求時遇到意外情況。

此外,該網站是www.nqmedia.co.uk讓人們看到它。

+0

有什麼不適合呢?沒有郵件?錯誤信息?讓你的「錯誤」文本顯示給你? – 2013-03-02 21:05:29

+0

你在你的php代碼中缺少'$ _POST'。另外,請確保在Gmail中檢查垃圾郵件文件夾。 – AustinAllover 2013-03-02 21:06:11

+0

即時通訊錯誤配置不正確。該網站是nqmedia.co.uk的聯繫方式 – 2013-03-02 21:06:30

回答

0

你的PHP更改爲以下:

<?php 
    $to ='[email protected]'; 
    $name = $_POST['name']; 
    $customer_mail = $_POST['customer_mail']; 
    $Subject = $_POST['Subject']; 
    $detail = $_POST['detail']; 

    $header="From: $name <$customer_mail>"; 

    $send_contact=mail($to,$Subject,$detail,$header); 

    if($send_contact){ 
     echo "We've recived your contact information"; 
    } else { 
     echo "ERROR"; 
    } 

?> 
  1. 沒有變量被正確定義,您需要使用$_POST從形式retrive值。

  2. $mail_from(現在的$customer_mail)在它被定義之前被使用。

  3. mail()函數中使用的參數以錯誤的順序使用。看看http://php.net/manual/en/function.mail.php

  4. 檢查您的表單上的action屬性。它說:「send.php」,但錯誤顯示「send_contact.php」

+0

嗨@ nine7ySix,所以我換了這些呢?對不起,該教程不是一個偉大的:S – 2013-03-02 21:11:27

+0

是的。嘗試看看它是否可行 – nine7ySix 2013-03-02 21:12:27

+0

嗨,它沒有工作:S – 2013-03-02 21:13:54

0

鑑於您的輸入端被命名相應 試試這個:

$name = $_POST['Name']; 
$mail_from = $_POST['customer_mail']; 
$header = "from: $name <$mail_from>"; 
$Subject = $_POST['Subject']; 
$detail = $_POST['detail']; 
0

你從來沒有真正抓住所有的崗位值。

將此代碼爲send.php:

<?php 
$name = $_POST['Name']; 
$mail_from = $_POST['customer_mail']; 
$subject = $_POST['Name']; 
$body = $_POST['detail']; 

$to ='[email protected]'; 

$header="from: $name <$mail_from>"; 

$send_contact=mail($to,$Subject,$body,$header); 

if($send_contact){ 
echo "We've received your contact information"; 
} 
else { 
echo "ERROR"; 
} 
?> 

此外,您打錯了,你的回聲「收到」,所以我固定的拼寫錯誤。

+0

嗨,那裏,我更新了我的代碼,它仍然不工作:S – 2013-03-02 21:19:17

+0

請編輯您的帖子併發布您的'.htaccess'。 – Pachonk 2013-03-02 21:22:08

+0

我不明白你的意思是什麼:s – 2013-03-02 21:22:57