Solved

trying to get remote ip in Wordpress footer, no results

Posted on 2011-03-11
3
1,643 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

If you are looking for plug-ins to add functions to your WordPress small business web site, take some time to read though this comprehensive list.  These are all the plugins I use for my customers WordPress web sites, as well as my own.  Be sure to …
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
This video teaches users how to migrate an existing Wordpress website to a new domain.

820 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