views:

225

answers:

3

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);
}
?>
+2  A: 

Hi,

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:

$HTTP_POST_VARS   = !empty($HTTP_POST_VARS)   ? $HTTP_POST_VARS   : $_POST;
ArneRie
This line that you've mentioned, should I add it just above the while loop?
nitbuntu
yepp , or repleace $HTTP_POST_VARS with $_POST in your sourcecode
ArneRie
+2  A: 

Probably there was a PHP upgrade on the server and $HTTP_POST_VARS has been deprecated. Use $_POST and $_GET for those.

Pentium10
So wherever it is written:- '$HTTP_POST_VARS', I should replace with '$_POST' and wherever it is wriiten '$HTTP_GET_VARS', I should replace with '$_GET'?
nitbuntu
yes, that's true...
Pentium10
A: 

Hi,

I have put my sites contact form up to download for free on my blog. http://moneymolder.com/blog/?p=47

Hopefully this helps people.

AndrewGoldie