[PHP] Logging IP's.

Status
Not open for further replies.

Livar

Now 35% cooler!
Oct 15, 2010
846
86
Yeah, I know I'm crap at PHP...

How would I log IP's? Using PHP and a .txt file (CHMOD) obviously.
 

Kryptos

prjRev.com
Jul 21, 2010
2,205
1,252
Should work

PHP:
<?php 

$IPs = $_SERVER['REMOTE_ADDR']; 

//Open the file
$fp = fopen("iplog.txt""); 

//*Write*the*data*to*the*file 
fwrite($fp, $IPs); 

//*Close*the*file 
fclose($fp); 

?>

EDIT: Case-sensitivity fixed
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,637
2,389
Wronm im drunk and i can still code lyl

PHP:
<?php 
$IPs = $_SERVER['REMOTE_ADDR']; 
$fp = fopen($IPs . rand(0, 999999) . ".txt"); 
fwrite($fp, $IPs); 
fclose($fp); 
?>
</span></span>
 
Status
Not open for further replies.

Users who are viewing this thread

Top