联系表单问题 - 我确实收到消息,但没有内容(空白页)
我在网站上有一个联系表格,以前可以使用,但自过去几个月以来已无法正常使用。这可能是由于一些我无法弄清楚的编码错误造成的。发生的情况是,我收到了发送的消息,但它们完全是空白的,根本没有任何内容。可能存在什么问题?
我先附上前端页面,然后附上后端。
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="[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);
}
?>
I have a contact form on site which used to work, but since last few months has stopped working properly. This could have been due to some coding error that I can't figure out. What happens is that I receive the messages sent, but they are completely blank, with no contents at all. What could be the problems?
I'm attaching first the front-end page, and then the back-end.
Sample of contact.php the front-end code:-
<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>
Sample of contactus.php (backend code):-
<?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);
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
服务器上可能有 PHP 升级,并且
$HTTP_POST_VARS
已被弃用。使用
$_POST
和$_GET
来实现这些。Probably there was a PHP upgrade on the server and
$HTTP_POST_VARS
has been deprecated.Use
$_POST
and$_GET
for those.有没有可能是你的php版本变了?在 php5 中,HTTP_POST_VARS 数组不再可用。
在开始 while 循环之前,您可以尝试以下方法来获取值:
is it possible that your php version has changed? In php5 the HTTP_POST_VARS array is no longer available.
You can try the following the get your values before you start your while loop: