-2

我从房东那里收到了此代码,用于我的联系表

<?php
$request_method = $_SERVER["REQUEST_METHOD"];
if($request_method == "GET")
{
    $query_vars = $_GET;
} 
elseif ($request_method == "POST")
{
    $query_vars = $_POST;
}

reset($query_vars);
$t = date("U");
$file = $_SERVER['DOCUMENT_ROOT'] . "\ssfm\gdform_" . $t;
$fp = fopen($file,"w");

while (list ($key, $val) = each ($query_vars)) 
{
    fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\r\n"); 
    fputs($fp,"$val\r\n");
    fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\r\n");
    if ($key == "redirect") 
    { 
        $landing_page = $val;
    }
}

fclose($fp);

if ($landing_page != "")
{
    header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
} 
else 
{
    header("Location: http://".$_SERVER["HTTP_HOST"]."/");
}
?>

我决定使用这个

<?php 
if ($_POST['parse_Var'] == "test_contact") {
    $email_title = 'New Email From Your Website';
    $my_email = 'alexeisrico@gmail.com';

    $email_field = $_POST['email'];
    $name_field = $_POST['name'];
    $message_field = $_POST['message'];

    $body = <<<EOD
<br><hr><br>
    Email: $email_field <br/>
    Name: $name_field <br/>
    Message: $message_field <br/>

EOD;

    $headers = "From: $email_field\r\n";
    $headers .= "Content-type: text/html\r\n";
    mail("$my_email", "$email_title", "$body", "$headers");

    header("location: http://www.phweshdeals.com/thanks.html");

}

?>

这是我的带有 PHP 扩展的 HTML 表单

<form action="config/test_contact.php" method="post">
                <ul>
                    <li><label for="name">Name:</label></li>
                    <li><input id="name" class="field" name="name" value="<?php print "$name_field"; ?>" placeholder="enter your name..." type="text" required><em>*required</em></li>


                    <li><label for="email">Email:</label></li>
                    <li><input id="email" class="field" name="email" value="<?php print "$email_field"; ?>" placeholder="enter your email..." type="email" required><em>*required</em></li>


                    <li>
                        <label for="message">Your Message</label>
                    </li>
                    <li>
                        <textarea id="message" name="message" value="<?php print "$messgae_field"; ?>" autocomplete="on" placeholder="type your message here..."></textarea><em>*required</em>
                    </li>


                    <li><input type="checkbox" required></li>
                    <li class="confirm">Confirm you are NOT a spammer</li>

                    <li><input type="submit" value="submit" style="background-color:#287472;
                        color:#fff;text-shadow:1px 1px #000; text-transform:uppercase;
                         font-weight:bold; border-radius:5px;"
                      id="submit_button"></li>
                      <input type="reset" value="clear!" style="background-color:#287472;
                        color:#fff;text-shadow:1px 1px #000; text-transform:uppercase;
                         font-weight:bold; border-radius:5px;"
                      id="reset_bg">
                </ul>
                <input type="hidden" name="parse_Var" id="parse_Var" value="test_contact">

        </form>

如果我使用我的主机的 php 代码,它不会捕获客户端填写表单时我想要捕获的所有输入字段。我决定创建我的,它甚至根本不起作用。如果我点击提交,我会在浏览器中收到这条消息;“没有指定输入文件。”。

我尝试了不同的 php 表单格式,但对我不起作用。问题可能来自我的主机吗?顺便说一句,这是我的主人;www.websitepalace.com。我已经联系了他们,但我无法得到任何切实的解决方案。我还听到一些主机故意为此控制/防止他们的客户向人们发送垃圾邮件或其他东西。不退出清除。拜托我需要你的帮忙。

4

1 回答 1

0

可能还有更多问题,但我首先看到的是:在所有输入字段中,更新 value 属性以从 PHP 变量中删除引号:

print "$name_field";

print $name_field;
于 2013-11-06T14:09:07.477 回答