Problem With $http_post_vars

free web hosting
Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Problem With $http_post_vars

kvarnerexpress
I have a piece of code on one server that works and the same piece of code on another server does not.
The difference is in the PHP verison & the Linux verison
The one that works runs PHP4 on Redhat Linux.
The one that doesn't runs PHP5 on SUSE Linux.
Not sure if this is where the issue lies or not. I do know that in one case I see an adrress in searchable and in the other case it is null.


PHP Code:
CODE

if ($HTTP_POST_VARS[addr])
{
    $searchable = $HTTP_POST_VARS[addr];
    echo "searchable = ".var_dump($searchable)."</br>";
    $stack=array();
...extra code
}
else
{
    print("<form method=\"POST\" action=\"ifinfo-single.php\"><table><tr><td><b>Enter IP/range/list: </td><td><input type=\"text\" name=\"addr\"></td><td><input type=\"submit\" value=\"Submit\"></td></tr></table>");
    print("<table><tr><td valign=top><b>Valid values: </td><td><font size=\"-1\"><ul><li>Single IP (172.16.32.152)</li><li>Range (172.16.32.140-144)</li><li>Semicolon seperated (172.16.32.140;172.16.32.151;172.16.32.152)</li></ul></td></tr></table>");

}  



Any ideas?

 

 

 


Reply

Spectre
I would suggest you use $_POST instead of $HTTP_POST_VARS. The former has superceded the latter - to the extent that I think some newer versions of PHP have alltogether dropped support for the previously used variable.

Also, I think it would probably a good idea to change the equivalent code above to:

CODE
if (isset($HTTP_POST_VARS['addr']) && $HTTP_POST_VARS['addr'] != '' )
{
    $searchable = $HTTP_POST_VARS['addr'];
    echo 'searchable = '.var_dump($searchable).'</br>';
    $stack=array();
...extra code
}
...


Remember to always enclose variable indexes (unless they are numeric) in quotes. $variable[index] may work on some systems, but $variable['index'] will work on all, and is a better standard of coding. Note that you should still replace $HTTP_POST_VARS with $_POST in the above block of code; I've just left it as is to make it easy to read.

Also, in the last section of your script, don't you think it would be easier to enclose the string in single quotes, and not have to escape every double quote you encounter?

CODE
    print('<form method="POST" action="ifinfo-single.php"><table><tr><td><b>Enter IP/range/list: </td><td><input type="text" name="addr"></td><td><input type="submit" value="Submit"></td></tr></table>');
    print('<table><tr><td valign=top><b>Valid values: </td><td><font size="-1"><ul><li>Single IP (172.16.32.152)</li><li>Range (172.16.32.140-144)</li><li>Semicolon seperated (172.16.32.140;172.16.32.151;172.16.32.152)</li></ul></td></tr></table>');

 

 

 


Reply

OpaQue
This piece of information might prove helpful..
QUOTE
The deprecation of the old $HTTP_*_VARS arrays (which need to be indicated as global when used inside a function or method). The following autoglobal arrays were introduced in PHP » 4.1.0. They are: $_GET, $_POST, $_COOKIE, $_SERVER, $_FILES, $_ENV, $_REQUEST, and $_SESSION. The older $HTTP_*_VARS arrays, such as $HTTP_POST_VARS, still exist and have since PHP 3. As of PHP 5.0.0, the long PHP predefined variable arrays may be disabled with the register_long_arrays directive.

Also, external variables are no longer registered in the global scope by default. In other words, as of PHP » 4.2.0 the PHP directive register_globals is off by default in php.ini



Reply

adly3000
i agree with OpaQue:
QUOTE
The deprecation of the old $HTTP_*_VARS arrays (which need to be indicated as global when used inside a function or method). The following autoglobal arrays were introduced in PHP » 4.1.0. They are: $_GET, $_POST, $_COOKIE, $_SERVER, $_FILES, $_ENV, $_REQUEST, and $_SESSION. The older $HTTP_*_VARS arrays, such as $HTTP_POST_VARS, still exist and have since PHP 3. As of PHP 5.0.0, the long PHP predefined variable arrays may be disabled with the register_long_arrays directive.

Also, external variables are no longer registered in the global scope by default. In other words, as of PHP » 4.2.0 the PHP directive register_globals is off by default in php.ini


just cahnge the ($HTTP_*_VARS arrays i.e. $HTTP_POST_VARS) to ($_* i.e. $_POST)

i also agree with Spectre:
using isset in trhe if statement is better than just if:
CODE
if (isset($_POST['addr']) && $_POST['addr'] != '' )
{
    $searchable = $_POST['addr'];
    echo 'searchable = '.var_dump($searchable).'</br>';
    $stack=array();
...extra code
}
...


the above code better than the following one:
CODE

if ($_POST['addr'])
{
    $searchable = $_POST['addr'];
    echo "searchable = ".var_dump($searchable)."</br>";
    $stack=array();
...extra code
}

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. http_post_vars - 2.44 hr back. (3)
  2. $http_post_vars php 5 does not work - 10.60 hr back. (1)
  3. $http_post_vars does not work - 10.81 hr back. (1)
  4. $http_post_vars - 1.59 hr back. (5)
  5. http_post_vars not working in linux - 17.19 hr back. (1)
  6. $http_post_vars, - 33.23 hr back. (1)
  7. http_post_vars php - 33.69 hr back. (1)
  8. fattureopen - 43.08 hr back. (1)
  9. $http_post_vars php 5 - 58.14 hr back. (1)
  10. http_post_vars not working - 5.33 hr back. (2)
  11. php http_post_vars - 70.07 hr back. (1)
  12. @$http_post_vars - 79.59 hr back. (1)
  13. not work $http_post_vars - 90.86 hr back. (1)
  14. http_post_vars php5 - 44.49 hr back. (2)
Similar Topics

Keywords : problem, http, post, vars

  1. Http_redirect() [resolved]
    (5)
  2. Flash + PHP: How can I transfer vars?
    (4)
    I am making a little section for a friends website. Here is what I have so far. :SWF File here:
    And I made it you match the layout of here site. Here As you can see I pretty much have the
    layout of it down. Some little bugs to be worked out with characters allowd in the text boxes and
    what not. But I have a good platform. NOW for the fun part! Getting vars from flash to send,
    via POST, to PHP. I have been trying to find a good tutorial on this online but I am not having such
    great outcomes! So if anyone can help me here please go for it! This is ....
  3. Compare Two Vars And Highlight The Differences
    (7)
    I need a script that compares 2 variables, and looks for a difference between them. It will then
    highlight the words that are different, as shown in the image below: So in the left cell, the
    yellow text is the text that has been removed OR replaced. In the right cell, the green text is the
    text that has replaced some text in the left cell, OR new text. This script will be used to
    compare 2 versions of a document stored in the database, to see the difference between each change
    (all revisions are stored in the database). I know that it's possible with PHP, beca....
  4. Http Authentication Without Using The Popup
    (3)
    As it is mentioned earlier on in this form I am trying to use HTTP authentication to add simple
    users control to my site, one thing I like about it is that the username and password are stored
    throught the entire session that way I don't have to enter into the realm of cookeis and session
    id's. So now I was wondering, a) can I use a standard html forum and place the password and
    username values into $_SERVER and $_SERVER so that they will be reembered throuout the
    session, and /cool.gif' border='0' style='vertical-align:middle' alt='cool.gif' /> ....
  5. Http Authentication
    (2)
    I have a book called PHP and MySQL for dynamic web sites by Larry Ullman, and it's a very good
    book which I would recomend to anyone wanting to learn, but I followed a project in this book, not
    letter by letter, and it won' work. I wrote this code to create an authentication script that
    will only work with one user but allow the credientals to be passed from one page to another. So
    here's the code CODE <?PHP $aut = FALSE;   //Check for user variables if (
    (isset($_server['PHP_AUTH_USER']) AND isset(�....
  6. Quick Question About Session Vars
    something I can't find anywhere (1)
    Can you save stuff like classes and arrays in sessionsvariables?....

    1. Looking for problem, http, post, vars

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for problem, http, post, vars

*MORE FROM TRAP17.COM*
advertisement



Problem With $http_post_vars



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE