I am beginner in PHP and I would like to store the users login time in another table called LoginHistory, I don't know how to write a query. Can u help me on that please?
<?php
include_once "conn.php";
if (!isset($_SESSION)) {
session_start();
}
if ($_SERVER['REQUEST_METHOD'] == "POST") {
if (empty($_POST["mobile_no"]) && empty($_POST["log_password"])) {
echo '<script>alert("Both Fields are required") </script>';
}
$sql = "select * from Users where Mobile='" . $_POST['mobile_no'] . "' and
Password='" . md5($_POST['log_password']) . "'";
if ($result = mysqli_query($conn, $sql)) {
$rowcount = mysqli_num_rows($result);
}
if ($rowcount > 0) {
$row = $result->fetch_assoc();
$_SESSION["userId"] = $row['Id'];
$_SESSION["ConstituencyId"] = $row['ConstituencyId'];
$succmsg = "Login Success";
header("location:user-login-welcome.php");
} else {
$errmsg = "Invalid Username / Password..";
}
}
?>