When a person logs into their account, I need a way of logging the date and time of it…
But I know a simple date stamp will do it, but how best to do it and logging each time without over writing the last one, so you get a full picture of each time they have logged in.
I am learning this stuff, but this is very urgent, so if anybody can help and be very clear and all, I will be very, very grateful.
Even better if it went to a .txt file or something, rather than the database
OK Ive gone with the code below:
$q1=mysql_query("select * from Register") or die (mysql_error());
while($data = mysql_fetch_assoc($q1))
{
$username=$_POST['myusername'];
$pass=md5($_POST['mypassword']);
if ($username==$data['Username'] && $pass==$data['Password'])
{
$error1="correct";
$_SESSION['user1']=$username;
$_SESSION['flaglog']=1;
$sql="insert into logdetails(Log_Id,dDate) values($data[Cod_Usu],now())";
$r=mysql_query($sql) or die ("insert into logdetails(Log_Id,dDate) values($data[RegId],now())<br><br>".mysql_error());
//header("location:main.php");
}
}
Ive set up the database called logdetails, I’m using the write info I think, and I’m coming back with this error.
insert into logdetails(Log_Id,dDate) values(302,now())
The 302 is correct in the error above, just not sure what the rest of the error is saying
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘now())’ at line 1
Its I got it, my bad, I didnt change a variable to reflect my code.
Seems to be working