Log in

View Full Version : $HTTP_POST_VARS Issue After PHP Upgrade



SChaput
02-11-2009, 11:37 PM
A few weeks ago the server i host my website from upgraded some of its information including its PHP. Because of this i had to change all the <? tags to <?php . Everything is back up and going fine but i am still seeing an issue when i try and pass variables to another page and then put them in my database.
the code in post.php is

<input name="hiddenField" type="hidden" id="hiddenField" value="<?php echo $bestsort; ?>">
<input name="hiddenField2" type="hidden" id="hiddenField2" value="<?php echo $prev; ?>">
<input name="hiddenField3" type="hidden" id="hiddenField3" value="<?php echo $sort; ?>">

And then those values are called in postw.php



<?php
mysql_connect("");
mysql_select_db("");


$time =$HTTP_POST_VARS["hiddenField"];
$preTime =$HTTP_POST_VARS["hiddenField2"];
$sort =$HTTP_POST_VARS["hiddenField3"];

$query ="INSERT INTO ws (time,preTime, sort)";
$query.="VALUES ('$time','$preTime','$sort')";
$result=mysql_query($query);
if ($result) echo "<b>Successfully Posted!</b>";
else echo "<b>ERROR: unable to post.</b>";

?>
<p><a href="index.php">Click Here to View</a></p>


When i navigate to these pages, the page labeled postw.php throws me this error.


Notice: Undefined variable: HTTP_POST_VARS in /u21/scsu/c/chaputs1/www/final2/w/postW.php on line 8

Notice: Undefined variable: HTTP_POST_VARS in /u21/scsu/c/chaputs1/www/final2/w/postW.php on line 9

Notice: Undefined variable: HTTP_POST_VARS in /u21/scsu/c/chaputs1/www/final2/w/postW.php on line 10
Successfully Posted!
Click Here to View


Is this due to the recent php upgrade on my server? if so, what do i need to change? Any help is appreciated, thanks!

Nile
02-12-2009, 12:18 AM
Use $_POST, now $HTTP_POST_VARS.
Or, at the top of your script put:


$HTTP_POST_VARS = $_POST;

Twey
02-12-2009, 06:17 PM
That won't necessarily work, since the new $HTTP_POST_VARS variable won't be autoglobal. You should really just be using $_POST. $HTTP_POST_VARS has been deprecated for several years now.