douge3830 2014-05-18 12:32
浏览 37

PHP - 如何显示上次登录[关闭]

I had been given a task to do some mini project. Right now I doing a registration, but I want to do last login date and time. When user login automatic date and time will update in the database. But i do not know, how to do it. I try doing like this and the time was have in the database but only show 0000-00-00 00:00:00. This was my SQL. I want the date and time been save same as my computer time. Hope you guys can help me ;)

<?php
session_start();
?>

<?php
require "cn.php";

$name=$_POST['Name'];
$ic_no=$_POST['Ic_No'];
$user=$_POST['Username'];
$time=date("h:i:s");
$_SESSION['CurrentUser']=$user;
$pass=$_POST['Mypass'];
$_SESSION['Currentpassword']=$password;
$email=$_POST['Email'];
$mbile=$_POST['Mobile_No'];

mysql_query("insert into reg (name,ic_no, user, pass, email, mbile,time)              values
('$name', '$ic_no', '$user', '$pass', '$email', '$mbile', '$time' )");

echo header("location: sucess.php");
?>
  • 写回答

2条回答 默认 最新

  • dongshetao1814 2014-05-18 12:51
    关注

    If you want to save time as mysql Timestamp value, you should format it like this:

    $now=time();
    $time=date('Y-m-d H:i:s', $now);
    

    Then you can always update it on user's login.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题