Jump to content

register global questions


boxcar182

Recommended Posts

i've just been looking through my php.ini file and i just read the part that goes.

[QUOTE]; You should do your best to write your scripts so that they do not require
; register_globals to be on;  Using form variables as globals can easily lead
; to possible security problems, if the code is not very well thought of.
register_globals = Off[/QUOTE]

but doesn't register globals have to be on to include pages like /?id=page here.

is there a way to get links working like that with register globals on then?
Link to comment
Share on other sites

no, you do not need register global on to enable any particular feature.

assume you have this kind of passing:

index.php?id=page&username=myname
and you want to print the username out.

with register global on, simply
echo $username;

without register global on,
echo $_GET['username'];

relying on register global is generally not good style.  There're many reason for it.

Bottom line is, accessing your GET and POST data via $_GET and $_POST

Link to comment
Share on other sites

When register_globals is off you have to use a set of predifined variables called superglobals. The following are the superglobas:
$_POST, $_GET, $_SESSION, $_COOKIe, $_SERVER

Basically to get session data you use $_SESSION, for cookies you use $_COOKIE, for server variables you use $_SERVER, for get/post'd data you you use $_GET or $_POST
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.