0

电子邮件是成功注销后的用户会话电子邮件,不存在电子邮件,但在索引页面上显示未定义的索引,因为注销后没有电子邮件。

Notice: Undefined index: email in C:\xampp\htdocs\CMS\index.php on line 9
    <?session_start();
?>
<?php
    require("conection/connect.php");   
    $username=$_SESSION['email'];
    $sel= "select * from users where email= '$username'";
    $run_name = mysqli_query($con, $sel);
    $row_user=mysqli_fetch_array($run_name);
    $name=$row_user['name'];
    $userid=$row_user['user_id'];
    $teacherid=$row_user['teacher_id'];
    $userid=$row_user['stu_id'];
    $usertype=$row_user['type'];
?>
4

1 回答 1

1

只需验证它是否已设置。无论如何,这可能对您有用,因为我假设如果设置,您可能想做一些不同的事情。

<?php

if (!isset($_SESSION['email'])) {
    // maybe redirect to login?
    // or at least don't show them logged-in user type stuff
}

// your code (in an else block if you didn't redirect in the if)
于 2017-12-05T21:01:58.497 回答