Home  >  Article  >  Backend Development  >  php 怎样获取当前客户端登陆用户的用户名解决方案

php 怎样获取当前客户端登陆用户的用户名解决方案

WBOY
WBOYOriginal
2016-06-13 10:16:551598browse

php 怎样获取当前客户端登陆用户的用户名
php 怎样获取当前客户端登陆用户的用户名 例如我要做一个论坛 我该如何获取当前客户端登陆的用户名 然后插入数据库中谢谢

------解决方案--------------------
登录的时候将一个唯一标识保存在SESSION中,比如用户表ID字段值
取的时候取这个SESSION在查出你需要的用户数据。


------解决方案--------------------

HTML code
<?phpif (!empty($_POST)){  //验证数据  ……  //插入数据库  mysql_query(……);  //将用户名存入会话  session_start();  $_SESSION['user'] = trim($_POST['username']);}?>
>".$_SESSION['user'];?>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn