Results 1 to 3 of 3

Thread: $HTTP_POST_VARS Issue After PHP Upgrade

  1. #1
    Join Date
    Feb 2008
    Posts
    90
    Thanks
    3
    Thanked 2 Times in 2 Posts

    Default $HTTP_POST_VARS Issue After PHP Upgrade

    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
    Code:
            <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

    Code:
    <?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!

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Use $_POST, now $HTTP_POST_VARS.
    Or, at the top of your script put:
    PHP Code:
    $HTTP_POST_VARS $_POST
    Jeremy | jfein.net

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •