[英]Notice: Undefined index: name in C:\wamp\www\chatsystem\index.php on line 63
I get this error... Its a chat system iver been working on for a couple of days. 我收到此错误...它的聊天系统已经运行了几天。 And the lines are:
这些行是:
<div id="wrapper">
<div id="menu">
<p class="welcome">Velkommen, <b><?php echo $_SESSION['name']; ?></b></p>
<p class="logout"><a id="exit" href="#">Forlad Chatten</a></p>
<script type="text/javascript">
// jQuery Document
$(document).ready(function(){
//If user wants to end session
$("#exit").click(function(){
var exit = confirm("Are you sure you want to end the session?");
if(exit==true){window.location = 'index.php?logout=true';}
});
});
</script>
You have to start your session at the top of your file with: 您必须使用以下命令在文件顶部开始会话:
session_start();
So you have access to the Session Array. 因此,您可以访问会话数组。
Also make sure you have set $_SESSION['name']
! 还要确保已设置
$_SESSION['name']
!
You can check if $_SESSION['name']
isset so you don't get a warning and it's only outputed when it is set like this: 您可以检查是否设置了
$_SESSION['name']
这样就不会收到警告,并且仅在设置如下时才输出警告:
<?php if (isset($_SESSION['name'])) echo $_SESSION['name']; ?>
I think you forgot to put a die() after loginFrom() on line 28 like so: 我认为您忘了在第28行的loginFrom()之后放置die(),如下所示:
if(!isset($_SESSION['name'])){
loginForm();
die();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.