2

我在现场有一个联系表,它曾经可以工作,但从最近几个月开始就停止了正常工作。这可能是由于一些我无法弄清楚的编码错误。发生的情况是我收到了发送的消息,但它们完全是空白的,根本没有内容。可能是什么问题?

我先附上前端页面,然后附上后端。

前端代码的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);
}
?>
4

2 回答 2

2

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

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

$HTTP_POST_VARS   = !empty($HTTP_POST_VARS)   ? $HTTP_POST_VARS   : $_POST;
于 2010-01-28T12:07:26.120 回答
2

服务器上可能有 PHP 升级并且$HTTP_POST_VARS已被弃用。使用$_POST$_GET为那些。

于 2010-01-28T12:07:38.380 回答