无法在PHP / MySQL中创建$ _SESSION?

时间:2013-03-14 22:18:47

标签: php mysql

ID  UID         Username    Full Name       Password    Rank
0   131037146   DSaidov     Денис Саидов    PASS        Администратор
0   1970687978  LKatzarov   Любомир Кацаров PASS        Администратор
0   58367315    Admin       Георги Гергинов PASS        Собственик

这是我的MySQL表; 我想创建一个$ _SESSION来保存当前登录CMS的用户的全名内容。 这是auth.php文件:

<?php
include("sql.php");
session_start();

function Destroy() {
    unset($_SESSION['UID']);
    unset($_SESSION['USERNAME']);
    unset($_SESSION['FULL NAME']);
    header("location: index-restricted.php");
}

if(isset($_SESSION['UID']) && isset($_SESSION['USERNAME'])) {
    $UID = $_SESSION['UID'];
    $username = $_SESSION['USERNAME'];
    $qry = mysql_query("SELECT * FROM `users` WHERE `UID` = '$UID' AND `Username` = '$username'");
    if(mysql_num_rows($qry) != 1) { Destroy(); }
} else { Destroy(); }?>

提前谢谢。

0 个答案:

没有答案