发送联系表格不工作

问题描述:

我已经按照发送联系表格的简单教程,但它似乎不工作。请有人协助请。下面发送联系表格不工作

形式:

<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

你的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

鉴于您的输入端被命名相应 试试这个:

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

你从来没有真正抓住所有的岗位值。

将此代码为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