Solved

trying to get remote ip in Wordpress footer, no results

Posted on 2011-03-11
3
1,639 Views
Last Modified: 2012-05-11
My theme calls a footer.php file for each page.

For a php script I am using for some specific tracking (not a plugin), I need to get the ip address of the visitor.

So in my footer.php, I put:

<? echo $_SERVER['REMOTE_ADDR']; ?>

But I don't get any results. Blank.

Also tried:

<? echo $REMOTE_ADDR; ?>

No results.

Any idea why and what I can do about it?
0
Comment
Question by:St_Aug_Beach_Bum
3 Comments
 
LVL 1

Accepted Solution

by:
MADDYIS earned 500 total points
Comment Utility
Please try below code to get remote ip address,

$_SERVER is an array containing information such as headers, paths, and script locations.
REMOTE_ADDR -- The IP address from which the user is viewing the current page.
getenv -- Gets the value of an environment variable

Output:

<?php
  echo "$_SERVER['REMOTE_ADDR']: ". $_SERVER['REMOTE_ADDR'] ."<br />";
  echo "getenv('REMOTE_ADDR'): ". getenv('REMOTE_ADDR') ."<br />";
?>
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
looks ok, worth checking that line is being rendered by echo some static text as well
Are you behind a proxy or anything like that?
0
 

Author Closing Comment

by:St_Aug_Beach_Bum
Comment Utility
Ah, thank you,  echo "getenv('REMOTE_ADDR'): did the trick :)
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Like there are many different versions of Wordpress, there are also a handful of related side projects WordPress users should be familiar with.   All of these projects are open source and GPL licensed, which means there are few restrictions to us…
Do you think that WordPress is just for blogs?  Think again!  WordPress is really a fantastic all around platform that you can use to develop websites on.  Integrated into its basic functionality is the ability to create pages using your choice of a…
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now