新手上路,求解答!当我从login.html跳转到homepage.html上时,如何在主页上显示“ XXX welcome!”。我用的是session,然后是从数据库读取的数据。
解决方案 »
- 全文搜索的问题
- 为什么连接memcache会有那么多错误的
- 用的是PEAR,,帮我找找原因吧..谢谢!
- 请问这里的高手,youtube.com这个刚被GOOGLE收购的网站是用什么语言写的
- php日期函数无法直接得到特定一日的星期几吧?中文的
- CURL 搞了 两天了 郁闷
- 首页index.php转换成index.html的问题 (与以前类似的话题不太一样。)
- 如何用JavaScript取得当前页面的URL、HTML源码和可见文本?
- 微信公众平台现在还能实现一键关注么?我试了很多都不行,据说都被tx屏蔽了?
- 数组转换成字符串的问题
- apache还在运行,但是网页打不开 求高手帮忙
- php oa系统介绍
if(isset($_SESSION['user'])) echo $_SESSION['user'] , ' welcome!';?>
中间是不是有检查的 php文件?或者你就写错了 两个都是php文件?
php文件session_start();
echo $_SESSION['UserName'];//这里的变量名为自己在login检测时定义的名称
中间是有个login.php 的检测页面的。
<?php
session_start();
//登录
if(!isset($_POST['submit'])){
exit('非法访问!');
}
$username = htmlspecialchars($_POST['username']);
$password = MD5($_POST['password']);//包含数据库连接文件
include('conn.php');
//检测用户名及密码是否正确
$check_query = mysql_query("select id from register where username='$username' and password='$password' limit 1");
if($result = mysql_fetch_array($check_query)){
//登录成功
$_SESSION['username'] = $username;
$_SESSION['userid'] = $result['id'];
echo"<script>location.href='homepage.html'</script>";
exit;
} else {
exit('登录失败!点击此处 <a href="javascript:history.back(-1);">返回</a> 重试');
}
?>
<?phpsession_start();
if(isset($_SESSION['username'])) echo $_SESSION['username'] , ' welcome!';?>
print_r($_SESSION);打印出来看有什么鸟。
Array ( [username] => aqin [userid] => 1 ) 是对的说。
将你的homepage.html 修改成homepage.php
所以,我白纠结了这么久桑感
大概用div&css写的主页会遮挡住我的输出内容
——————————
怎么可能呢。
贴出你的跳转后的代码,肯定是有错误滴
echo “$_SESSION[usename]欢迎您”;
?>