Home  >  Article  >  Backend Development  >  PHP 从登陆界面跳转到主页时主页面显示的有关问题

PHP 从登陆界面跳转到主页时主页面显示的有关问题

WBOY
WBOYOriginal
2016-06-13 13:50:001296browse

PHP 从登陆界面跳转到主页时主页面显示的问题
新手上路,求解答!当我从login.html跳转到homepage.html上时,如何在主页上显示“ XXX welcome!”。我用的是session,然后是从数据库读取的数据。

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

session_start();
if(isset($_SESSION['user'])) echo $_SESSION['user'] , ' welcome!';

?>
------解决方案--------------------
从login.html 跳转到 homepage.html 你不可能直接就跳到了 homepage.html吧?
中间是不是有检查的 php文件?或者你就写错了 两个都是php文件?
php文件

session_start();
echo $_SESSION['UserName'];//这里的变量名为自己在login检测时定义的名称
------解决方案--------------------
homepage.html是静态页面,能读到SESSION吗?
------解决方案--------------------
就是嘛。
将你的homepage.html 修改成homepage.php

探讨

homepage.html是静态页面,能读到SESSION吗?
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