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!

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.

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

Thanks for the help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.