![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Feb 2005
Location: UK
Posts: 3
Rep Power: 0
![]() |
HTML / IP addresses
Ok, im not sure if this is in the right place, but here goes. Also i hope it doesnt sound too.. 'dodgy'.
What sort of code (language or otherwise) would a site like Whatismyip.com use to return the IP to the user? I'm not new to web programming with HTML / Java but im by no means advanced. I would also like to know what code (again language or otherwise) would I need to retreive data on what browser users that visit my site are using. Any help will be appreciated ![]() Thanks Al |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Oct 2004
Location: England, UK
Posts: 139
Rep Power: 0
![]() |
using PHP
<?php $ip = phpinfo(REMOTE_ADDR); echo 'Your IP addy is '; echo $ip; ?> I've not tested it as I am at college, but in theory it will work ![]()
__________________
Don't wound what you can't kill |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Oct 2004
Location: England, UK
Posts: 139
Rep Power: 0
![]() |
OR....
<?php echo "User's IP address: " . $_SERVER["REMOTE_ADDR"]; ?> Found that on a website I googled.
__________________
Don't wound what you can't kill |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Feb 2005
Location: UK
Posts: 3
Rep Power: 0
![]() |
Cool, thanks man.
Anyone have any idea where the IE info is stored / found? Al |
|
|
|
|
|
#5 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Just search $_SERVER['HTTP_USER_AGENT'] for "MSIE":
[php]$ie = (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) ? true : false;[/php] |
|
|
|
|
|
#6 |
|
Newbie
Join Date: Feb 2005
Location: UK
Posts: 3
Rep Power: 0
![]() |
Ahh! Brilliant! THanks very much guys. Now i just have to get it to write the findings to my database hehe. A job for another day maybe
![]() |
|
|
|
|
|
#7 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Enjoy yourself.
|
|
|
|
|
|
#8 |
|
Programming Guru
![]() |
It's just $_SERVER["REMOTE_ADDR"]
__________________
|
|
|
|
|
|
#9 |
|
Programmer
|
Ooble: Nice, but overly complex. :p Here is an easy way to find out if the user is using IE with regular expressions:
[php]<?php if (preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT'])) { // do whatever you need to } ?>[/php] I use that to fix IE's CSS rendering issues with my website. Like, how IE requires negative margins for certain alignments. It's pretty sick... so PHP is the only way to go when fixing the bullshit IE throws onto the screen. :/
__________________
/* LANCE */ C++; /* this makes C bigger but returns the old value */ char *site = "slackwise.net", *home = "lance.slackwise.net", *pics = "flickr.com/photos/slackwise"; |
|
|
|
|
|
#10 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Well, using my code, you can pull out the useful bit if there's only one if statement you want to use it in:
[php]if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) { ... }[/php] |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|