/    Sign up×
Community /Pin to ProfileBookmark

sender’s ip address

IN PHP:

[code=php]
$useripaddy = $_SERVER[‘REMOTE_ADDR’];
[/code]

Very simple form email. When we receive it, we would like to show the ip address of the sender, to keep for our records. The above is not working, it show’s our ip address instead of the sender. How do I fix this? It’s on a secure https, it make a difference?

Thank you

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@LeeUJan 24.2008 — Try this:
[code=php]
$useripaddy = getenv("REMOTE_ADDR");[/code]
Copy linkTweet thisAlerts:
@xoxLISAxoxauthorJan 25.2008 — Thank you Lee but it's not working, giving me the same results.

?
Copy linkTweet thisAlerts:
@LeeUJan 25.2008 — Can you post the entire code?
Copy linkTweet thisAlerts:
@hex1a4Jan 25.2008 — Hi,

This will work:
[code=php]$useripaddy = $_SERVER[REMOTE_ADDR];[/code]
Copy linkTweet thisAlerts:
@xoxLISAxoxauthorJan 25.2008 — same thing

?

this is frustrating.

i have read other posts that worked, how come mines don't
Copy linkTweet thisAlerts:
@hex1a4Jan 26.2008 — What version of PHP are you running? If earlier than 4.1 try this:
[code=php]$useripaddy = $HTTP_SERVER_VARS['REMOTE_ADDR'];[/code]
Copy linkTweet thisAlerts:
@xoxLISAxoxauthorJan 26.2008 — I tried that does not work either.

I just called our provider and they said php version 4.4.2.

Thanks so much, hope this gets resolved soon.
Copy linkTweet thisAlerts:
@hex1a4Jan 26.2008 — This might be a configuration issue. Contact your hosting provider's tech support and ask them. [code=php]$_SERVER[REMOTE_ADDR][/code] [i]is[/i] correct and [i]should[/i] work.
Copy linkTweet thisAlerts:
@TechEvangelistJan 27.2008 — hex1a4 is correct.

$_SERVER['REMOTE_ADDR'] should work.

If you are testing it yourself, then it will, of course, show your IP address.

Make sure that you are using this within a script that is being requested by the client (user's browser) and not a script being initiated by the server.

$_SERVER['REMOTE_ADDR'] is the IP address of the entity running the script.
×

Success!

Help @xoxLISAxox 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.16,
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,
)...