/    Sign up×
Community /Pin to ProfileBookmark

Hi,

how can i get the user’s IP address?
it’s very important, i want to ban some serious rule-breakers.

[i]-Insane[/i]

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@JDM71488Nov 18.2005 — http://www.php.net knows, but here you go:
<?php echo $REMOTE_ADDR ?>
Copy linkTweet thisAlerts:
@SpectreReturnsNov 18.2005 — Wrong. Use $_ENV["REMOTE_ADDR"], because the other one will only work with register_globals on, and thus causes big security holes.
Copy linkTweet thisAlerts:
@tbirnsethNov 18.2005 — Hmm... I think you need a php.ini setting to get it into the environment too. So why not use: $_SERVER['REMOTE_ADDR'] which is where both the above get their info anyway?
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYNov 18.2005 — Yeah, use the Server superglobal
Copy linkTweet thisAlerts:
@JDM71488Nov 19.2005 — wow, i didn't know it would cause security holes. sorry. i thought that $remote_addr and $_server['remote_addr'] was the same thing security wise...

my appologies
Copy linkTweet thisAlerts:
@SpectreReturnsNov 19.2005 — Hrem, I thought that REMOTE_ADDR was populated in the environment, thus the use of get_env() to read it. Oh well.
Copy linkTweet thisAlerts:
@Daniel_TNov 19.2005 — wow, i didn't know it would cause security holes. sorry. i thought that $remote_addr and $_server['remote_addr'] was the same thing security wise...[/QUOTE]register_globals() causes all superglobals to be assigned to normal variable names by their keys. For example, $_SERVER['REMOTE_ADDR'] would become $remote_addr. Likewise, $_GET['REMOTE_ADDR'] could become $remote_addr, so someone could send a different IP address by adding [i]remote_addr=123.45.678.910[/i] to the querystring.
Copy linkTweet thisAlerts:
@bokehNov 19.2005 — $_server['remote_addr'][/QUOTE][B]Note:[/B] the server array is upper case: [B]$_SERVER['REMOTE_ADDR'][/B]
Copy linkTweet thisAlerts:
@insaneauthorNov 19.2005 — thanks guys. you really helped me.

[i]-Insane[/i]
×

Success!

Help @insane spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...