Computing.Net > Forums > Web Development > php register globals on/off how/why

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

php register globals on/off how/why

Reply to Message Icon

Name: huummmm
Date: November 25, 2004 at 15:01:48 Pacific
OS: win2000
CPU/Ram: 512
Comment:

Hi all. I'm pretty new to php and am just after a few hints if poss. I'm just trying out some simple scripts using global variables (i.e. $REMOTE_ADDR) etc. and i'm getting errors 'Notice: Undefined variable: REMOTE_ADDR in c:\Inetpub\wwwroot\INDEX.php on line 22'. I've read a little into this and am I right in saying that this is down to the register globals being set to off (i'm using php 5 by the way).
Thanks for any help.
Owen



Sponsored Link
Ads by Google

Response Number 1
Name: -Bryan-
Date: November 25, 2004 at 16:58:38 Pacific
Reply:

To answer the why...register globals being on is a security mess waiting to happen, as global variables can ultimately be overwritten using malicious script, etc.

Try using $_SERVER['REMOTE_ADDR']array instead.


0

Response Number 2
Name: FBI Agent
Date: November 29, 2004 at 07:58:04 Pacific
Reply:

also, if you have a lot of variables on your forms it slows them down because they have to create a useless variable for each piece on the form whether or not it will be used. reg globals are for lazy loser web-designers, if you want them on you shouldnt be making websites. but yeah, for the newer versions of php you do what bryan mentioned. you should check out the phpinfo(). just do:

<?php
echo phpinfo()
?>

and open the .php webpage. it will show a list of all the php stuff and at the bottom it will show you some predefined variables that you can use and what they mean.

FBI Agent

AIM: EliteAssassin187


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


php and IIS setup problem How do I enable CGI in my...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: php register globals on/off how/why

Error in PHP Script www.computing.net/answers/webdevel/error-in-php-script/2599.html

$PATH php error www.computing.net/answers/webdevel/path-php-error/294.html

PHP- Open Results on new Page? www.computing.net/answers/webdevel/php-open-results-on-new-page/211.html