注意:未定义索引:C:\xampp\htdocs\deped2\index.php中的管理员注意:未定义索引:C:\xampp\htdocs\deped2\index.php中的用户
这是我的密码注意:未定义索引:C:\xampp\htdocs\deped2\index.php中的管理员注意:未定义索引:C:\xampp\htdocs\deped2\index.php中的用户,php,Php,这是我的密码 <?php include("include/dbcon.php"); if($_SESSION['admin']){ //this is where the error starts header("location:admin/"); }else if($_SESSION['users']){ //and here also header('location:employee/'); }else{ header:('location
<?php
include("include/dbcon.php");
if($_SESSION['admin']){ //this is where the error starts
header("location:admin/");
}else if($_SESSION['users']){ //and here also
header('location:employee/');
}else{
header:('location:/deped2/');
}
?>
请帮我处理此代码您没有检查会话索引是否已设置。最好先启动会话,然后检查变量是否存在 尝试此操作并添加退出;在每个标题之后。否则,您的代码可能希望继续执行
<?php
if(!isset($_SESSION)){
session_start();
}
include("include/dbcon.php");
if(isset($_SESSION['admin'])){ //this is where the error starts
header("location:admin/");
exit;
}else if(isset($_SESSION['users'])){ //and here also
header('location:employee/');
exit;
}else{
header:('location:/deped2/');
exit;
}
?>
chk会话,你是否开始了会话除了当前的答案可以解决你的问题外,我建议使用exit;在每个标题“Location:…”之后。我将把include放在条件下面。如果失败,那么它将抛出headers sent警告并添加exit;在每一个标题后面都有一个更好的答案。是的,你可以把include放在条件后面。