![](/img/trans.png)
[英]Notice: Undefined index: in C:\wamp\www\tests\Joomla\Website\index.php on line 37
[英]Notice: Undefined index: name in C:\wamp\www\chatsystem\index.php on line 63
我收到此錯誤...它的聊天系統已經運行了幾天。 這些行是:
<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>
您必須使用以下命令在文件頂部開始會話:
session_start();
因此,您可以訪問會話數組。
還要確保已設置$_SESSION['name']
!
您可以檢查是否設置了$_SESSION['name']
這樣就不會收到警告,並且僅在設置如下時才輸出警告:
<?php if (isset($_SESSION['name'])) echo $_SESSION['name']; ?>
我認為您忘了在第28行的loginFrom()之后放置die(),如下所示:
if(!isset($_SESSION['name'])){
loginForm();
die();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.