Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 9th, 2005, 7:03 AM   #1
BlindPilot
Newbie
 
BlindPilot's Avatar
 
Join Date: Feb 2005
Location: UK
Posts: 3
Rep Power: 0 BlindPilot is on a distinguished road
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
BlindPilot is offline   Reply With Quote
Old Feb 9th, 2005, 8:11 AM   #2
Ade
Hobbyist Programmer
 
Ade's Avatar
 
Join Date: Oct 2004
Location: England, UK
Posts: 139
Rep Power: 0 Ade is an unknown quantity at this point
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
Ade is offline   Reply With Quote
Old Feb 9th, 2005, 8:14 AM   #3
Ade
Hobbyist Programmer
 
Ade's Avatar
 
Join Date: Oct 2004
Location: England, UK
Posts: 139
Rep Power: 0 Ade is an unknown quantity at this point
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
Ade is offline   Reply With Quote
Old Feb 9th, 2005, 9:37 AM   #4
BlindPilot
Newbie
 
BlindPilot's Avatar
 
Join Date: Feb 2005
Location: UK
Posts: 3
Rep Power: 0 BlindPilot is on a distinguished road
Cool, thanks man.

Anyone have any idea where the IE info is stored / found?

Al
BlindPilot is offline   Reply With Quote
Old Feb 9th, 2005, 10:29 AM   #5
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Just search $_SERVER['HTTP_USER_AGENT'] for "MSIE":
[php]$ie = (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) ? true : false;[/php]
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Feb 10th, 2005, 6:54 AM   #6
BlindPilot
Newbie
 
BlindPilot's Avatar
 
Join Date: Feb 2005
Location: UK
Posts: 3
Rep Power: 0 BlindPilot is on a distinguished road
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
BlindPilot is offline   Reply With Quote
Old Feb 10th, 2005, 1:47 PM   #7
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Enjoy yourself.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Feb 21st, 2005, 10:04 PM   #8
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 6 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
It's just $_SERVER["REMOTE_ADDR"]
__________________

tempest is offline   Reply With Quote
Old Feb 26th, 2005, 6:10 AM   #9
Lance
Programmer
 
Lance's Avatar
 
Join Date: Oct 2004
Location: Chicago, IL USA
Posts: 74
Rep Power: 5 Lance is on a distinguished road
Send a message via AIM to Lance
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";
Lance is offline   Reply With Quote
Old Feb 26th, 2005, 9:10 AM   #10
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
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]
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:39 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC