Choose fontsize:
Welcome, Guest. Please login or register.
Did you miss your activation email?

 

Pages: [1]   Go Down
  Print  
Author Topic: PHP - Simple Viewing of IP Address + Browser/OS  (Read 6468 times)
0 Members and 1 Guest are viewing this topic.
Member
*

Karma: 3
Gender: Male
Posts: 151


View Profile WWW
« on: January 27, 2006, 08:08:03 PM »
[h1]Simple Viewing of IP Address + Browser/OS[/h1]
Here is a simple PHP code that returns the viewers IP address, and what browser/OS they are using. I have added in comments, so it's easy to follow. Hope you like it, though it doesn't do much, it is sorta cool. By the way, comments are referring to the line of code ABOVE the comment.

Code:
<?php
//This is just saying that what follows is PHP code.
echo "Your IP Address is " ;
//When you have echo before something, it means what folows on that line will come out as text. The next text is just in their so the viewer knows what the numbers that follows are. Make sure you have a space after is but before the end quote.
echo $_SERVER['REMOTE_ADDR'];
//This code will display the IP address. Again, echo will display whatever follows, which in this case is code that grabs the IP address.
echo " and your browser is " ;
//This is just using echo again, and putting in the text and your browser is. Make sure to have a space after the first quote, and another before the second.
echo $_SERVER["HTTP_USER_AGENT"];
//This line of code simplys grabs the names of the browser, and displays it with echo.
?>


And the very last line just ends the PHP code. Very similiar to closing a HTML tag. Now, here is a version of the code without the comments.

Code:
<?php
   
echo "Your IP Address is " ;
   echo 
$_SERVER['REMOTE_ADDR'];
   echo 
" and your browser is " ;
   echo 
$_SERVER["HTTP_USER_AGENT"];
?>


I hope you enjoyed my simple tutorial. Smiley If you have questions, comments, or suggestions, either post in this thread, or email me at "rmjohnson307 [at] gmail [dot] com". (Change the [at] to @ and [dot] to a period)

Example Page:
Click here to see an example of this script.

If you like this tutorial, please Click here to register.

Click the link below to download the PHP file for this tutorial.
Simple Viewing of IP Address + Browser/OS PHP
« Last Edit: February 10, 2006, 07:36:32 PM by SKETCHi » Logged
Tutorial Writer
*

Karma: 4
Gender: Male
Posts: 1,114



View Profile WWW
« Reply #1 on: January 29, 2006, 03:12:53 PM »
Nice, and easy to use script! Note to thoes who are like "What can I use this for?!" -
A database! Say you've got a forum with a mean user, BAN HIS IP!
Or a flash portal, make it so only 5 votes a day from an IP!
Each IP is a diff computer (unless someone meses around)
Logged
Administrator
*

Karma: 51
Gender: Male
Posts: 2,638



View Profile WWW
« Reply #2 on: January 29, 2006, 06:16:54 PM »
I can have thousands of IPs Smiley.

Nice examples though ssj, and great tutorial Capt.
Logged
Member
*

Karma: 3
Gender: Male
Posts: 151


View Profile WWW
« Reply #3 on: February 01, 2006, 11:49:14 PM »
No need to be a show off SKETCHi, later I might make a tut on how to get their real IP. Wink
Logged
Administrator
*

Karma: 51
Gender: Male
Posts: 2,638



View Profile WWW
« Reply #4 on: February 01, 2006, 11:51:32 PM »
MAC address never changes...
Logged
Tutorial Writer
*

Karma: 4
Gender: Male
Posts: 1,114



View Profile WWW
« Reply #5 on: February 02, 2006, 05:16:24 PM »
bzzzert, wrong sketchi, need to completely re-set internet XD All you do (if router / modem), turn the modem off for about 30 - 60 seconds, then on again, should have a new MAC
Logged
Administrator
*

Karma: 51
Gender: Male
Posts: 2,638



View Profile WWW
« Reply #6 on: February 02, 2006, 05:27:36 PM »
Changing your MAC address is a bad idea... Most ISPs use it to track registered, paying users...

Edit: I found this article on changing it, which also does a decent job explaining.

http://compnetworking.about.com/od/networkprotocolsip/a/macaddressing_2.htm

Anyway, no more... this is getting off topic.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:      

BioRUST [ In: 2951 // Out: 2428 ] Flawsome [ In: 446 // Out: 1726 ] MickM [ In: 2403 // Out: 2118 ] SMF Topsites [ In: 0 // Out: 2021 ] Graphic Addicts Topsites [ In: 2435 // Out: 3389 ] Vero Graphics [ In: 509 // Out: 1591 ] IMG Share [ In: 612 // Out: 1712 ] Xtreme-Pixel [ In: 118 // Out: 1640 ]
Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC
Phobos design by Bloc | XHTML | CSS


Google visited last this page Yesterday at 10:30:54 PM