联系表格问题 - 我收到消息,但没有内容(空白页)

时间:2010-01-28 11:49:01

标签: php email forms hosting contact

我在网站上有一个曾经工作的联系表格,但是自上个月以来一直停止正常工作。这可能是由于我无法弄清楚的一些编码错误。发生的事情是我收到发送的消息,但它们完全是空白的,根本没有内容。可能是什么问题?

我首先附加前端页面,然后附加后端。

contact.php的示例前端代码: -

<div id="content">
     <h2 class="newitemsxl">Contact Us</h2>

<div id="contactcontent">
        <form method="post" action="contactus.php">
Name:<br />
<input type="text" name="Name" /><br />
Email:<br />
<input type="text" name="replyemail" /><br />
Your message:<br />
<textarea name="comments" cols="40" rows="4"></textarea><br /><br />

<?php require("ClassMathGuard.php"); MathGuard::insertQuestion(); ?><br /> 
  <input type="submit" name="submit" value="Send" />
* Refresh browser for a different question. :-)

</form>
</div>

</div>

contactus.php示例(后端代码): -

<?php

/* first we need to require our MathGuard class */
require ("ClassMathGuard.php");
/* this condition checks the user input. Don't change the condition, just the body within the curly braces */
if (MathGuard :: checkResult($_REQUEST['mathguard_answer'], $_REQUEST['mathguard_code'])) {
    $mailto="questions@stylishgoods.com";
$pcount=0;
$gcount=0;
$subject = "A Stylish Goods Enquiry";
$from="DO_NOT_reply@stylishgoods.com";
echo ("Great, you're message has been sent !"); //insert your code that will be executed when user enters the correct answer
} else {
    echo ("Sorry, wrong answer, please go back and try again !"); //insert your code which tells the user he is spamming your website
}


while (list($key,$val)=each($HTTP_POST_VARS))
{
$pstr = $pstr."$key : $val \n ";
++$pcount;
}
while (list($key,$val)=each($HTTP_GET_VARS))
{
$gstr = $gstr."$key : $val \n ";
++$gcount;
}
if ($pcount > $gcount)
{
$comments=$pstr;
mail($mailto,$subject,$comments,"From:".$from);
}
else
{
$comments=$gstr;
mail($mailto,$subject,$comments,"From:".$from);
}
?>

2 个答案:

答案 0 :(得分:2)

你的php版本可能已经改变了吗?在php5中,HTTP_POST_VARS数组不再可用。

您可以在开始while循环之前尝试以下方法获取您的值:

$HTTP_POST_VARS   = !empty($HTTP_POST_VARS)   ? $HTTP_POST_VARS   : $_POST;

答案 1 :(得分:2)

可能在服务器上进行了PHP升级,并且$HTTP_POST_VARS已被弃用。 请使用$_POST$_GET