<?php
$filename = 'iplog.txt';
$somecontent = $_SERVER["REMOTE_ADDR"];
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$fp = fopen($filename, 'a')) {
print "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (!fwrite($fp, $somecontent)) {
print "Cannot write to file ($filename)";
exit;
}
print "ip logged";
fclose($fp);
} else {
print "The file $filename is not writable";
}
?>
it works, it writes the IP of users to the txt file, but how can i make it write more than one thing(browser, ip, refferer, etc) and how can i makre it do a line break after each.