我在网站上有一个曾经工作的联系表格,但是自上个月以来一直停止正常工作。这可能是由于我无法弄清楚的一些编码错误。发生的事情是我收到发送的消息,但它们完全是空白的,根本没有内容。可能是什么问题?
我首先附加前端页面,然后附加后端。
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);
}
?>
答案 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
。