我的联系表格不起作用

时间:2013-11-05 14:51:04

标签: php html forms

我从我的主人那里收到了我的联系表格

<?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。我联系了他们,但我无法得到任何切实的解决方案。我还故意听到一些主持人控制/阻止他们的客户向人们发送垃圾邮件。不戒烟。 拜托,我需要你的帮助。

1 个答案:

答案 0 :(得分:0)

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

print "$name_field";

print $name_field;