Php 联系人表单问题-我确实收到消息,但没有内容(空白页)
我在网站上有一个联系方式,以前是有效的,但从最近几个月开始就不能正常工作了。这可能是由于一些我无法理解的编码错误造成的。结果是我收到了发送的消息,但是它们完全是空白的,没有任何内容。有什么问题吗 我先贴上前端页,然后贴上后端页 contact.php前端代码示例:-Php 联系人表单问题-我确实收到消息,但没有内容(空白页),php,email,forms,hosting,contact,Php,Email,Forms,Hosting,Contact,我在网站上有一个联系方式,以前是有效的,但从最近几个月开始就不能正常工作了。这可能是由于一些我无法理解的编码错误造成的。结果是我收到了发送的消息,但是它们完全是空白的,没有任何内容。有什么问题吗 我先贴上前端页,然后贴上后端页 contact.php前端代码示例:- <div id="content"> <h2 class="newitemsxl">Contact Us</h2> <div id="contactcontent">
<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="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);
}
?>
联系我们
名称:
电子邮件:
您的留言:
*刷新浏览器以获取其他问题。:-)
contactus.php示例(后端代码):-
您的php版本可能已更改吗?在php5中,HTTP_POST_VARS数组不再可用
在开始while循环之前,可以尝试以下方法获取值:
$HTTP_POST_VARS = !empty($HTTP_POST_VARS) ? $HTTP_POST_VARS : $_POST;
服务器上可能有PHP升级,$HTTP\u POST\u VARS
已被弃用。
使用$\u POST
和$\u GET
。因此,无论写在哪里-“$HTTP\u POST\u VARS”,我都应该替换为“$\u POST”,无论写在哪里,$HTTP\u GET\u VARS,我都应该替换为“$\u GET”?您提到的这一行,我应该将它添加到while循环的正上方吗?是的,或者在源代码中使用$\u POST回复$HTTP\u POST\u VARS