I am creating a back office website , and need to trace the operations done on the website , for that I need a to generate a log file of every operation for example : Date-Time -User-Operation. I have tried files but did not really work
$query_add="UPDATE auth_table SET etat = replace(etat,'$anc','$nv') where user_id LIKE
'%$log%'";
$query_exec=mysql_query($query_add) or die(mysql_error());
?><script language='JavaScript'>alert('Activation termine')</script><?
$date = date("Y-d-m");
$heure = date("H:i");
$op=$date.$heure.'Activation du compte de'.$log.'par administrateur'.$logad;
$fp = fopen('log.txt', 'w');
fseek($fp,0);
fputs($fp, $op);
fclose($fp);
Any idea on how to do this ?
$query_add="UPDATE auth_table SET etat = replace(etat,'$anc','$nv') where user_id LIKE
'%$log%'";
$query_exec=mysql_query($query_add) or die(mysql_error());
?><script language='JavaScript'>alert('Activation termine')</script><?
$date = date("Y-d-m");
$heure = date("H:i");
$op=$date.$heure.'Activation du compte de'.$log.'par administrateur'.$logad;
$op .= "
";
$file = 'log.txt';
$search = file_get_contents($file);
$check = strpos($search, $log);
if ($check === FALSE) {
$fp = @fopen($file, 'a');
$write = @fputs($fp, $op);
@fclose($fp);
}
That would work, assuming $log
and $logad
have already been defined.