|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
Try $_SERVER['REMOTE_ADDR']
The IP address from which the user is viewing the current page. |
|
#3
|
|||
|
|||
|
thanks but how do I use this code? embed it into my HTML page?
|
|
#4
|
||||
|
||||
|
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.
|
|
#5
|
|||
|
|||
|
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 |
|
#6
|
||||
|
||||
|
Try:
PHP Code:
Perhaps a few beginner tutorials wouldn't hurt either... ;-) |
|
#7
|
||||
|
||||
|
Here's an example of some of the things you are trying to use..
Try this: save it as userip.php PHP Code:
check this page out for more information on all of the predefined variables..: http://us4.php.net/reserved.variables Hope this helps. |
|
#8
|
|||
|
|||
|
Thank you
I have it working now, Many thanks
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > IP address on web page via PHP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|