我有一个登录脚本和一个带字段的表,这里需要的是'avatar'(varchar(255)& defaul entry是图像链接)
查看个人资料的代码:
<div align="center"><img src="<?php echo $_GET['avatar']; ?>" width="250" height="250" /></div>
会话代码:
function set_session($username, $password) {
$query = $this->query("SELECT * FROM ".DBTBLE." WHERE username='$username' AND password='$password'");
ini_set("session.gc_maxlifetime", Session_Lifetime);
session_start();
$_SESSION['first_name'] = $query['result']['first_name'];
$_SESSION['last_name'] = $query['result']['last_name'];
$_SESSION['email_address'] = $query['result']['email_address'];
$_SESSION['username'] = $query['result']['username'];
$_SESSION['info'] = $query['result']['info'];
$_SESSION['user_level'] = $query['result']['user_level'];
$_SESSION['password'] = $query['result']['password'];
$_SESSION['avatar'] = $query['result']['avatar'];
}
没有添加头像的功能,所以我在表单中添加了show <div>
函数,在名为avatar的数据库中创建了一个列,并添加了$_SESSION['avatar'] = $query['result']['avatar']
但默认图片不是显示,我哪里出错了?除了头像外,其他所有内容都已显示。
答案 0 :(得分:0)
src="<?php echo $_GET['avatar']; ?>"
应该是:
src="<?php echo $_SESSION['avatar']; ?>"