I am maintaining two tables:
- Employee table consists of username and password(for logging in)
- log table consists of login and logout time for the session user
With the click of a button, I should be able to capture/insert the time and session user to log table.
Here is my code for logging time and session user:
<?php
session_start();
if($_SESSION['username']) {
$user = $_SESSION['username'];
$tin= $_POST["timein"];
$conn = mysql_connect("localhost","root","");
mysql_select_db("attendance", $conn);
$query = "INSERT INTO log (user, timein) VALUES ($user , NOW())";
mysql_query($query, $conn);
echo "<h2>you have logged your time!</h2>";
mysql_close($conn);
}
?>
SHOW CREATE TABLE log;
statement to your question, and try running this on yourmysql
server:INSERT INTO log (user, timein) VALUES (1 , NOW())