PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 20th, 2004, 10:28 AM
jasper jasper is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: UK
Posts: 5 jasper User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m
Reputation Power: 0
IP address on web page via PHP

Hi,

I am totally new to PHP but know that it is possible to use it to display a visitors Ip address on an HTML web page.

Please tell me what I need to do, step by step, to get this working. I am good with HTML but a real novice with PHP.

I have checked and my web space supports PHP4 scripting.
Do I need to upload anything to the web server or just embed the script into my HTML pages.

many thanks

Reply With Quote
  #2  
Old January 20th, 2004, 11:55 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
Try $_SERVER['REMOTE_ADDR']
The IP address from which the user is viewing the current page.

Reply With Quote
  #3  
Old January 21st, 2004, 03:49 AM
jasper jasper is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: UK
Posts: 5 jasper User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m
Reputation Power: 0
thanks but how do I use this code? embed it into my HTML page?

Reply With Quote
  #4  
Old January 21st, 2004, 07:35 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Well, it'd have to be a PHP page. Or you could use server side includes in HTML. It's been a while since I've done anything with that, but you should be able to find more about them at apache.org. You can access environment variables through SSI.

Reply With Quote
  #5  
Old January 21st, 2004, 08:46 AM
jasper jasper is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: UK
Posts: 5 jasper User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m
Reputation Power: 0
I'm using the code:

<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php $ip = $REMOTE_ADDR; ?>
</body>
</html>

and saving the file as "myip.php" but it doesn't work

Reply With Quote
  #6  
Old January 21st, 2004, 09:05 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
Try:

PHP Code:
<?php echo $REMOTE_ADDR?>



Perhaps a few beginner tutorials wouldn't hurt either... ;-)

Reply With Quote
  #7  
Old January 21st, 2004, 09:31 AM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 653 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 m 52 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
Here's an example of some of the things you are trying to use..

Try this: save it as userip.php
PHP Code:
<?
$hst 
$_SERVER["HTTP_HOST"];
$uri $_SERVER["REQUEST_URI"];
$rmt $_SERVER["REMOTE_ADDR"];
$br $_SERVER["HTTP_USER_AGENT"];
echo 
"Your IP address reflects as : $rmt \n<br>\n The page you requested was: $uri \n<br>\n The browser you are using is $br";
?>


check this page out for more information on all of the predefined variables..: http://us4.php.net/reserved.variables

Hope this helps.

Reply With Quote
  #8  
Old January 22nd, 2004, 12:04 PM
jasper jasper is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: UK
Posts: 5 jasper User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m
Reputation Power: 0
Thank you

I have it working now, Many thanks

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > IP address on web page via PHP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT