欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

我想让这个blog.php页面把登陆的用户名打印出来应该怎么写呢?

程序员文章站 2023-12-23 19:18:15
...
blog.php
 

cookie页面

login.php

prepare("select id,username,password from user where username=? and password=?");
 $stmt->execute(array($_POST['username'],($_POST['password'])));
 if($stmt->rowCount()>0){
 list($id,$username)=$stmt->fetch(PDO::FETCH_NUM);
   $time=time()+24*60*60;
   setCookie("uid",$id,$time,"/");
   setCookie("username",$username,$time,"/");
   setCookie("isLogin",1,$time,"/");
   echo '';
 }
 else{
     echo "登陆失败";
 }
 }
?>


用户名: 密码:

回复内容:

blog.php

 

cookie页面

login.php

prepare("select id,username,password from user where username=? and password=?");
 $stmt->execute(array($_POST['username'],($_POST['password'])));
 if($stmt->rowCount()>0){
 list($id,$username)=$stmt->fetch(PDO::FETCH_NUM);
   $time=time()+24*60*60;
   setCookie("uid",$id,$time,"/");
   setCookie("username",$username,$time,"/");
   setCookie("isLogin",1,$time,"/");
   echo '';
 }
 else{
     echo "登陆失败";
 }
 }
?>


用户名: 密码:

setCookie("username",$username,$time,"/");

echo $username;//打印用户名
相关标签: php

上一篇:

下一篇: