Solved

trying to get remote ip in Wordpress footer, no results

Posted on 2011-03-11
3
1,645 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

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

WordPress has made it easy to create scalable sites based on their powerful CMS, but as great as WordPress is, there are some SEO issues that haven’t been addressed out of the box.  Fortunately these problems can be solved with a few plugins.  The f…
How to install BuddyPress on your self-hosted WordPress site It’s been called everything from “social networking in a box” to “Facebook without the terms of service,” but until Feb. 16, BuddyPress was a relatively unknown outside the WordPress MU…
The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and SmallPDF.com Log…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
Suggested Courses

624 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