Originally posted by paulsim
I have just started to work with register_globals = Off in PHP4.3 on W2K.
Have I got it right?
A variable called username comes from a post form with a value of "Fred".
I can echo this OK in the next page with
echo $_POST['username'] - it shows Fred
My understanding is that this POST variable should be available in all subsequent pages as long as session_register() is used at the top of the page.
BUT the value of $_POST['username'] reverts to NULL once I am past the page immediately after the form.
ie echo $_POST['username'] gives a blank.
What am I doing wrong??? or where am I mixed up????
and Weedpacket wrote:-
No, you're thinking of $SESSION[]. $POST[] contains form data supplied by a POST request from the previous page only.
Thanks for that. I wonder why they are called superglobals.
I think semiglobals is a better name and keep the term superglobal for $_SESSION.
I wonder if I was the only thicko fooled by this.
The only way that $_POST etc is global as far as I can see is that it can be seen in functions called from that page - without having to assign them as being global. This is valuable of course, but hardly superglobal.
So is it reasonable to keep user name and password in $_SESSION so that it can be used for accessing the database; or is there a better way.
Seems to me that $_SESSION variables can be altered almost as easily as the old session variables.
Paul