0

我有一个登录脚本和一个带有字段的表,这里需要的是“头像”(varchar(255)&默认条目是一个图像链接)

查看配置文件的代码:

<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'];

}   

没有添加头像的功能,所以我<div>在表单中添加了显示功能,在数据库中创建了一个名为头像的列,并添加了$_SESSION['avatar'] = $query['result']['avatar']但默认图像不显示,我哪里出错了?除头像外,其余均显示。

4

1 回答 1

0
src="<?php echo $_GET['avatar']; ?>"

应该:

src="<?php echo $_SESSION['avatar']; ?>"
于 2013-05-12T10:28:55.407 回答