0
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(); }?>

先感谢您。

4

0 回答 0