简体   繁体   English

注意:未定义的索引:第63行的C:\\ wamp \\ www \\ chatsystem \\ index.php中的名称

[英]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.

相关问题 注意:未定义的索引:在第37行的C:\\ wamp \\ www \\ tests \\ Joomla \\ Website \\ index.php中 - Notice: Undefined index: in C:\wamp\www\tests\Joomla\Website\index.php on line 37 注意:未定义的变量:第7行的C:\\ wamp \\ www \\ cbmall \\ index.php中的db_host - Notice: Undefined variable: db_host in C:\wamp\www\cbmall\index.php on line 7 我有错误:注意:未定义偏移量:C:\\ wamp \\ www \\ index.php在32行,34行,36行,38行的C:\\ wamp \\ www \\ index.php中 - I have error:Notice: Undefined offset: 1 in C:\wamp\www\index.php on line 32,on line 34,on line 36,on line 38 复选框值未获取-&gt;注意:未定义的索引:第27行的C:\\ wamp \\ www \\ crud_exer1 \\ content.php中的name1 - checkbox value not get -> Notice: Undefined index: name1 in C:\wamp\www\crud_exer1\content.php on line 27 注意:未定义的索引:第46行的C:\\ wamp \\ www \\ upload.php中的fileToUpload - Notice: Undefined index: fileToUpload in C:\wamp\www\upload.php on line 46 注意:未定义的索引:第164行的C:\\ wamp \\ www \\ blog \\ news.php中的pre - Notice: Undefined index: pre in C:\wamp\www\blog\news.php on line 164 注意:未定义偏移量:1 in C:\\xampp\\htdocs\\index.php 第 5 行 - Notice: Undefined offset: 1 in C:\xampp\htdocs\index.php on line 5 PHP错误提示:未定义的索引:第35行的C:\\ wamp \\ www \\ tweetball \\ classes \\ word.class.php中的UserID - Php error Notice: Undefined index: UserID in C:\wamp\www\tweetball\classes\word.class.php on line 35 未定义索引:在第 4 行输入 C:\\wamp\\www\\submit.php - Undefined index: type in C:\wamp\www\submit.php on line 4 未定义索引:第 4 行 C:\wamp\www\emailvalidate.php 中的电子邮件 - Undefined index: email in C:\wamp\www\emailvalidate.php on line 4
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM