Solved

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

Posted on 2004-09-08
13
720 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
  • 5
  • 4
13 Comments
 
LVL 4

Accepted Solution

by:
iceboxman earned 63 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 62 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

786 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