【发布时间】:2017-12-05 20:56:55
【问题描述】:
电子邮件是成功注销后的用户会话电子邮件,不存在电子邮件,但在索引页面上显示未定义的索引,因为注销后没有电子邮件。
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'];
?>
【问题讨论】:
-
如何执行注销?可能是通过取消会话?那么 $_SESSION 是一个空数组,访问 $_SESSION['email'] 会抛出一个警告
-
window.open('../index.php', '_self')"; ?>
-
这是我的登出页面。代码。 window.open('../index.php', '_self')"; ?>
-
那么你不应该访问 $_SESSION['email'] ;)
-
如果登录用户关闭页面并进入主页,我已设置它。应该有一个已经登录的状态,这很好。但是注销后它会显示未定义索引的通知。
标签: php session undefined-variable