联系表单问题 - 我确实收到邮件,但没有内容(空白页)

问题描述:

我在网站上有一个联系表单,但过去几个月已停止正常工作。这可能是由于一些编码错误,我无法弄清楚。会发生什么是我收到发送的消息,但它们完全是空白的,根本没有内容。可能是什么问题?联系表单问题 - 我确实收到邮件,但没有内容(空白页)

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

样品contact.php的前端代码: - contactus.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> 

样品(后端代码): -

<?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="[email protected]"; 
$pcount=0; 
$gcount=0; 
$subject = "A Stylish Goods Enquiry"; 
$from="[email protected]"; 
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); 
} 
?> 

也许有些服务器上的PHP的升级和$HTTP_POST_VARS已被弃用。 使用$_POST$_GET

+0

因此无论它写在哪里:''HTTP_POST_VARS',我应该用'$ _POST'替换,无论它在哪里被'$ HTTP_GET_VARS'取代,我应该用'$ _得到'? – nitbuntu 2010-01-28 12:25:02

+0

是的,这是真的... – Pentium10 2010-01-28 13:05:07

是有可能,你的PHP版本已经改变?在php5中,HTTP_POST_VARS数组不再可用。

你可以试试下面您启动while循环之前,让你的价值观:

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

您提到的这行代码,我应该在while循环之上添加它吗? – nitbuntu 2010-01-28 12:27:25

+0

yepp,或者在你的源代码中用$ _POST重新获得$ HTTP_POST_VARS – opHASnoNAME 2010-01-28 12:52:29