?
Solved

How to make website like www.showmyip.com in PHP language

Posted on 2004-09-08
13
Medium Priority
?
725 Views
Last Modified: 2008-02-01
Any body tell me how to make something just like www.showmyip.com in PHP language, Which have to give all informations About user on the single page.

I know this is possible in PL and CGI but i need this stuff in php.
i am not a BIG programmer of php thats why i am asking this question.
0
Comment
Question by:shanino
[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
  • 5
  • 4
13 Comments
 
LVL 4

Accepted Solution

by:
iceboxman earned 252 total points
ID: 12007170
Use something like:

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

This will display the IP address of the remote user. Take a look at the link below for some more interesting variables.

http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server
0
 
LVL 4

Expert Comment

by:iceboxman
ID: 12007180
Oops, forgot the semicolon

<?php
echo $_SERVER['REMOTE_ADDR'];
?>
0
 
LVL 1

Assisted Solution

by:x-tinct
x-tinct earned 248 total points
ID: 12007550
To see all that is stored in the _SERVER array:

<html>
<body>
<pre>
<?php
  print_r($_SERVER);  // prints all elements of the server array
?>
</pre>
</body>
</html>

It is not very pretty, but there you can see what you can get.
0
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
LVL 2

Expert Comment

by:Rajkumar_G
ID: 12013166
echo "<br>Server Varibles : ";
   echo "<pre>";
    print_r($_SERVER);  // prints all elements of the server array
   echo "</pre>";

   echo "<br>Environment Variables : ";
   echo "<pre>";
    print_r($_ENV);  // prints all elements of the Environment array
   echo "</pre>";

   echo "<br>Cookies :  ";
   echo "<pre>";
    print_r($_COOKIE);  // prints cookies data
   echo "</pre>";

   echo "<br>Session Variables : ";
   echo "<pre>";
    print_r($_SESSION);  // prints session values
   echo "</pre>";


from these find out what is your requirement
0
 
LVL 1

Expert Comment

by:x-tinct
ID: 12013513
$_ENV does not contain client information, only server info.
$_COOKIES and $_SESSION is only variables you have stored on the client and is useless for anyone else than the server developer.

If you want browser information like resulution and stuff, you will have to use javascript. Take a look at the sourcecode of the page you referred to see how this is done.

If you want country information, you will need to use some a IP-country service. Maxmind.com has a PHP module that implements this.
http://www.maxmind.com/app/php
0
 
LVL 1

Expert Comment

by:x-tinct
ID: 12493097
Part of the question: "...give ALL informations about USER..."

iceboxman answer is correct, but didn't answer the question. (ALL info)
Rajkumar_G answer is also correct, but it describes how to show server info instead of user info. (about USER)

The site http://www.showmyip.com/ shows info from the client request, dns lookup, country lookup and browser info from javascript as I answered.
0
 
LVL 4

Expert Comment

by:iceboxman
ID: 12506307
Actually, my answer did include showing all information:

I gave a reference to the PHP variables that display all the information that is needed.  The rest of the people pretty much regurgitated what I said.

"This will display the IP address of the remote user. Take a look at the link below for some more interesting variables.

http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server"
0
 
LVL 4

Expert Comment

by:iceboxman
ID: 12506332
The information displayed on www.showmyip.com can all be obtained by looking at the information provided.
0
 
LVL 1

Expert Comment

by:x-tinct
ID: 12513332
Ok, sorry about the link. That is true, the information in the $_SERVER variable is described there. But this can not give all the information about the user that is displayed on showmyip.com. Take a closer look, it does for instance not include screen resolution, nor does it include country information (only prefered language or ip address), etc...

So I suggest we split the points if ok by iceboxman?
0
 
LVL 4

Expert Comment

by:iceboxman
ID: 12513555
Your right.  Screen resolution can only be given by JavaScript.  You can see that if you look at the page source of www.showmyip.com.

As for the point split, that's fine.
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

770 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