PDA

View Full Version : PHP IP?



Liburd
30-05-2008, 07:04 PM
How do I get a users ip in php?

--ss--
30-05-2008, 07:09 PM
$ip = $_SERVER['REMOTE_ADDR'];
Then use the $ip variable for what ever you want to do.

Liburd
30-05-2008, 07:15 PM
i want to php include on my website though? how do i make it into a file?

--ss--
30-05-2008, 07:18 PM
i want to php include on my website though? how do i make it into a file?
Sorry but that doesn't make any seance?
I'm guessing you want to display it?


$ip = $_SERVER['REMOTE_ADDR'];
echo ("Your ip is $ip");

Liburd
30-05-2008, 07:23 PM
Lol, say i have index.php and I want to include a file say ip.php what do I put in the ip.php file to make it show on my index.php page?

--ss--
30-05-2008, 07:26 PM
Lol, say i have index.php and I want to include a file say ip.php what do I put in the ip.php file to make it show on my index.php page?
To include the file called ip.php you would put this php code in your index.php file:

<?php include("ip.php"); ?>

Liburd
30-05-2008, 07:27 PM
Ive tryed that but dont work :S www.habboinfo.co.uk its jsut blank :S

--ss--
30-05-2008, 07:30 PM
Ive tryed that but dont work :S www.habboinfo.co.uk (http://www.habboinfo.co.uk) its jsut blank :S
Because you have no content in your ip.php file?

By looking at your site i'm guessing you want to show their actual ip, this is done by echoing it out;).

<?php $ip = $_SERVER['REMOTE_ADDR'];
echo ("$ip"); ?>

Liburd
30-05-2008, 07:32 PM
thank you! works now +rep

Decode
30-05-2008, 07:33 PM
thank you! works now +rep
:O ive seen the nav buttons on your site on another fansite.

Jackboy
31-05-2008, 07:54 AM
Wow i thought everyone on this forum knew php :P

Php.net ftw

Independent
31-05-2008, 03:37 PM
ip.php (Source):


<?php
echo $_SERVER['REMOTE_ADDR']
?>

INDEX.PHP SOURCE:
(ADD TO IT)


<?php
include("ip.php");

Decode
31-05-2008, 03:39 PM
ip.php (Source):


<?php
echo $_SERVER['REMOTE_ADDR']
?>
INDEX.PHP SOURCE:
(ADD TO IT)


<?php
include("ip.php");

You forgot the ?> at the end.

Hypertext
31-05-2008, 04:40 PM
Ruby ftw.

Liburd you definitely sound like the guy who coded habbo myspace...and a rare panel was it?

Want to hide these adverts? Register an account for free!