Solved

trying to get remote ip in Wordpress footer, no results

Posted on 2011-03-11
3
1,640 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
ID: 35114102
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
ID: 35114103
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
ID: 35114241
Ah, thank you,  echo "getenv('REMOTE_ADDR'): did the trick :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Did you use a default hosting installation of wordpress with the intention of it being your actual site?  Maybe you’ve installed it as a Blog to your current site and recently converted it to be the main site and do away with the old .htm pages.  An…
WordPress can be pretty daunting, especially for a beginner, so I thought it might be a good idea to write an article to show how easy it is to get started in WordPress and to design a custom theme.  The first step is to check with your hosting comp…
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

867 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

23 Experts available now in Live!

Get 1:1 Help Now