Page 1 of 1
[SOLVED] Post vars
Posted: Sat Nov 29, 2003 8:52 am
by oldtimer
I am doing work on some pages on a server that is php 4.0.6 and mine is 4.1.2. On my server i can go $_POST[value] on theirs it will not work. Neither will adding a ' or a " around value. I can however do $HTTP_POST_VARS[value]. What can I tell this person to do to make it so that the $_POST works?
Help is appreciated.
Posted: Sat Nov 29, 2003 9:17 am
by mchaggis
Ooooo I know this one... I have servers of same spec... it's annoying ain't it...
Ok, several questions:
1) Do you admin the server... ie do you have access to the php.ini file?
2) is the an standard include file that is included in all of their scripts... if so try:
Code: Select all
<?php $_POST = $HTTP_POST_VARS; ?>
Posted: Sat Nov 29, 2003 9:37 am
by oldtimer
1) No I dont have access but the admin does and he will try what I suggest.
2) Not sure what you mean there.
Posted: Sat Nov 29, 2003 9:49 am
by mchaggis
Ok, well the php.ini file edit of auto_prepend is out if u don't have access to thephp.ini file... oh well...
What I meant be no. 2 is....
I have scipts in a web site that ALL include a series of standard files, such as:
initialise.php - contains all the initialisation of sessions, cookies, variables, db connections etc.
header.php - contains the header for the html
footer.php - need i explain
initialise.php is included at the begining of every script in my site, so a skeletal page would look a bit like:
Code: Select all
<?php
require_once $HTTP_SERVER_VARS["DOCUMENT_ROOT"]."/include/initialise.php";
require_once $HTTP_SERVER_VARS["DOCUMENT_ROOT"]."/include/footer.php";
// ALL code goes here
require_once $HTTP_SERVER_VARS["DOCUMENT_ROOT"]."/include/footer.php";
?>
So if you had any files like that then you could just make the first line the statement I mention above
Posted: Sat Nov 29, 2003 10:02 am
by oldtimer
Okay I see what you mean. where as i include a config file on every page I could have the $_POST = $HTTP_POST_VARS; in that as well. That would work great. First I will have the person edit their php.ini file first. I know he will want to get it to where just the _Post works.
Posted: Sat Nov 29, 2003 1:00 pm
by oldtimer
What would I edit in the php.ini. I just got access to it.
Posted: Sat Nov 29, 2003 1:39 pm
by m3mn0n
Your problem is not an ini configuration; rather the server version.
$_POST was added to PHP in
4.1.0.
http://www.php.net/manual/en/reserved.v ... ables.post
HTTP POST variables: $_POST
Note: Introduced in 4.1.0. In earlier versions, use $HTTP_POST_VARS.
An associative array of variables passed to the current script via the HTTP POST method. Automatically global in any scope.
This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don't need to do a global $_POST; to access it within functions or methods, as you do with $HTTP_POST_VARS.
$HTTP_POST_VARS contains the same initial information, but is not an autoglobal. (Note that HTTP_POST_VARS and $_POST are different variables and that PHP handles them as such)
If the register_globals directive is set, then these variables will also be made available in the global scope of the script; i.e., separate from the $_POST and $HTTP_POST_VARS arrays. For related information, see the security chapter titled Using Register Globals. These individual globals are not autoglobals.
I suggest telling the server admin to upgrade to a newer version.
Posted: Sat Nov 29, 2003 1:46 pm
by oldtimer
Thank you. Now we just need to see if he can safely upgrade and not mess up his Cobalt 550

I will get this information to him.
Posted: Sat Nov 29, 2003 1:55 pm
by m3mn0n
No problem. Good luck with that!

Posted: Sat Nov 29, 2003 3:32 pm
by mchaggis
.... Hoever, if you cannot update (what with it being a cobalt and all) what I was hinting at with the php.ini file is the 'auto_prepend_file =' line
You need to set this as a file that contains the above code.
If however, you can upgrade php then great, wish all of us where that lucky!
Posted: Sat Nov 29, 2003 8:22 pm
by oldtimer
Ahh. so i change this line.
to
Code: Select all
auto_prepend_file = $_POST = $HTTP_POST_VARS;
??
I do have access to the file and I can add anything that needs to be added.
Posted: Sat Nov 29, 2003 9:26 pm
by m3mn0n
I believe that ini setting includes a file within all the pages on the server.
It's been a while since I used it and I can't find info within the manual about it. I might be a bit off with the info below...
So
auto_prepend_file = /postvarsupdate.php would fix your problem if that page contained something like this:
As is says in the quote above; "
You don't need to do a global $_POST; to access it within functions or methods, as you do with $HTTP_POST_VARS."
Wouldn't that cause some issues with scripts that don't use
global $_POST; or
global $HTTP_POST_VARS; after a
function definition? I'd guess so.