Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

trying to get remote ip in Wordpress footer, no results

Posted on 2011-03-11
3
Medium Priority
?
1,649 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 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Now that you've installed WordPress 2.9 (http://www.experts-exchange.com/articles/Web_Development/Blogs/WordPress/WordPress-2-9-What-to-Expect-When-Upgrading-to-WordPress-2-9.html?) on your site, you need to install some plugins to get the most out …
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
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…
Suggested Courses
Course of the Month11 days, 17 hours left to enroll

916 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