0

Hello!

I created a login form that is connected to the MySQL database, what i wanted to do now is to record who successfully login to the form and will also record the time and date he/she login

Can you give me some hint on how to do it

Thanks!

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by dudzkie
0

What you would be best doing is creating a new table to hold this data in your SQL something like "login_records" and every time you create a session for a member logging in you insert a new row.

So on your login page just before or just after you create the session/cookie simply just add in an addition like:

$user = $session[username]; // session users name
$date = date("d/m/Y"); // turns timestamp time into a read-able date
$time = date("g:i a", $dat); // turns timestamp time into a read-able time
$dat = time(); // Gets the current server time in a timestamp form
$insert = mysql_query("INSERT INTO `login_records`(id, username, date, time) VALUES ('', '$user', '$date', '$time')");

Your SQL table that holds these would require `id` to be the primary key with an auto increase. Then it is up to you what you are going to do with these rows :)

Hope this helped.

Edited by public-image: n/a

0

a just got i little confuse its just like register an account script

Thanks for the help!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.