dsfjk44656
2018-10-11 05:28
浏览 65
已采纳

如何在mysql PHP中插入用户登录日期时间[关闭]

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..";
}
}
?>
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题