Reputation: 1
My code attempt uses php functions fopen(), date(), time(), fwrite() and fclose(). There are a few examples I have found (e.g. w3schools)that use several of the components I need but, in my hands, no joy.
First attempt at code to be included eventually in a bigger page:
<html>
<head>
</head>
<body>
<?php
$logfilename = 'HitRecorder.log';
$logfile=fopen($logfilename,"a");
$remaddr = $_SERVER["REMOTE_ADDR"];
if(isset($_SERVER['HTTP_X_SUCURI_CLIENTIP'])) {
$remaddr = $_SERVER['HTTP_X_SUCURI_CLIENTIP'];
$_date=date("d/m/Y");
$_time=date("H:i");
fwrite($logfile,$_date."\t".$_time."\t"$remaddr,"\n");
fclose($logfile);
echo $_date."\t".$_time."\t".$remaddr."<br>";
?>
</body>
</html>
This does not access the text file and the echo() produces: "; ?>
Upvotes: 0
Views: 21