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 ='kirsty.harris1985@gmail.com';

    $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 供人们查看。

4

3 回答 3

0

将您的 PHP 更改为以下内容:

<?php
    $to ='kirsty.harris1985@gmail.com';
    $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它从表单中检索值。

  2. $mail_from(now $customer_mail) 在定义之前使用。

  3. 函数中使用的参数mail()顺序错误。看http://php.net/manual/en/function.mail.php

  4. 检查action表单上的属性。它说“send.php”,但错误显示“send_contact.php”

于 2013-03-02T21:08:24.993 回答
0

鉴于您的输入已相应命名,请尝试以下操作:

$name = $_POST['Name'];
$mail_from = $_POST['customer_mail'];
$header = "from: $name <$mail_from>";
$Subject = $_POST['Subject'];
$detail = $_POST['detail'];
于 2013-03-02T21:13:37.207 回答
0

你从来没有真正抓住所有的帖子价值。

将此作为 send.php 的代码:

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

$to ='kirsty.harris1985@gmail.com';

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

此外,您在回声中拼写错误“received”,所以我修正了拼写错误。

于 2013-03-02T21:14:59.723 回答