title: getting Notice: Undefined index: text in .... at line 4
body: <pre><code>4:$textik = $_POST['text'];
  </code></pre>
  
  <p>and im getting</p>
  
  <blockquote>
    <p><strong>notice:</strong> Undefined index: text in <strong>path/to/script</strong> on line 4.</p>
  </blockquote>
  
  <p>why?</p>
  
  <p>the url is
  <br><code>http://somesite.domain/path/to/script?text=something</code><br>
  Thanks for answers  </p>
  
  <p>edit:
  full script in path/to/script is</p>
  
  <pre><code> &lt;?php
  session_start();
  if(isset($_SESSION['name'])){
      $textik = $_POST['text'];
      date_default_timezone_set(date_default_timezone_get());
      $time = date('h:i', time()); 
      $fp = fopen("log.html", 'a');
      fwrite($fp, "&lt;li class='other'&gt;
        &lt;div class='msg'&gt;
            &lt;div class='user'&gt;".$_SESSION['name']."&lt;/div&gt;
          &lt;p&gt;".stripslashes(htmlspecialchars($textik))."&lt;/p&gt;
          &lt;time&gt;".$time."&lt;/time&gt;
        &lt;/div&gt;
      &lt;/li&gt;");
      fclose($fp);
  }
  ?&gt; 
  </code></pre>
  
  <p>and in path/to/anotherscript is</p>
  
  <pre><code>&lt;?php
  session_start ();
  function loginForm() {
      echo '
      &lt;div id="loginform"&gt;
      &lt;form action="index.php" method="post"&gt;
          &lt;p&gt;Please enter your name to continue:&lt;/p&gt;
          &lt;label for="name"&gt;Name:&lt;/label&gt;
          &lt;input type="text" name="name" id="name" /&gt;
          &lt;input type="submit" name="enter" id="enter" value="Enter" /&gt;
      &lt;/form&gt;
      &lt;/div&gt;
      ';
  }
  
  if (isset ( $_POST ['enter'] )) {
      if ($_POST ['name'] != "") {
          $_SESSION ['name'] = stripslashes ( htmlspecialchars ( $_POST ['name'] ) );
          $fp = fopen ( "log.html", 'a' );
          date_default_timezone_set(date_default_timezone_get());
      $time = date('h:i', time());
          fwrite ( $fp, "&lt;p class='notification'&gt; ". $_SESSION ['name'] . " left the group &lt;time&gt;". $time."&lt;/time&gt;&lt;/p&gt;" );
          fclose ( $fp );
      } else {
          echo '&lt;span class="error"&gt;Please type in a name&lt;/span&gt;';
      }
  }
  
  if (isset ( $_GET ['logout'] )) {
  
      // Simple exit message
      $fp = fopen ( "log.html", 'a' );
      fwrite ( $fp, "&lt;div class='msgln'&gt;&lt;i&gt;User " . $_SESSION ['name'] . " has left the chat session.&lt;/i&gt;&lt;br&gt;&lt;/div&gt;" );
      fclose ( $fp );
  
      session_destroy ();
      header ( "Location: index.php" ); // Redirect the user
  }
  
  ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;link rel='stylesheet' type='text/css' href='new.css'&gt;
  &lt;title&gt;AZsites chat&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;?php
      if (! isset ( $_SESSION ['name'] )) {
          loginForm ();
      } else {
          ?&gt;
  &lt;div id="wrapper"&gt;
      &lt;ol class="chat"&gt;
          &lt;div class="menu"&gt;
              &lt;a href="#" class="back"&gt;&lt;i class="fa fa-angle-left"&gt;&lt;/i&gt; &lt;img src="https://i.imgur.com/G4EjwqQ.jpg" draggable="false"/&gt;&lt;/a&gt;
              &lt;div class="name"&gt;AZsites chat&lt;/div&gt;
      &lt;div class="members"&gt;&lt;b&gt;&lt;?php echo $_SESSION['name']; ?&gt;&lt;/b&gt; a dalsi&lt;/div&gt;
          &lt;/div&gt;&lt;?php
          if (file_exists ( "log.html" ) &amp;&amp; filesize ( "log.html" ) &gt; 0) {
              $handle = fopen ( "log.html", "r" );
              $contents = fread ( $handle, filesize ( "log.html" ) );
              fclose ( $handle );
  
              echo $contents;
          }
          ?&gt;&lt;/ol&gt;&lt;/div&gt;
      &lt;div class="typezone"&gt;
  &lt;form name="message" action='' method='post'&gt;&lt;textarea name="text" id="usermsg" size="63"type="text" placeholder="Napis neco"&gt;&lt;/textarea&gt;&lt;input type="submit" class="send" value="odeslat"/&gt;&lt;/form&gt;
  &lt;div class="emojis"&gt;&lt;/div&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;script type="text/javascript"
          src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
  // jQuery Document
  $(document).ready(function(){
  });
  
  //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';}      
      });
  });
  
  //If user submits the form
  $("#submitmsg").click(function(){
          var clientmsg = $("#usermsg").val();
          $.post("post.php", {text: clientmsg});              
          $("#usermsg").attr("value", "");
          loadLog;
      return false;
  });
  
  function loadLog(){     
      var oldscrollHeight = $("#chatbox").attr("scrollHeight") - 20; //Scroll height before the request
      $.ajax({
          url: "log.html",
          cache: false,
          success: function(html){        
              $("#chatbox").html(html); //Insert chat log into the #chatbox div   
  
              //Auto-scroll           
              var newscrollHeight = $("#chatbox").attr("scrollHeight") - 20; //Scroll height after the request
              if(newscrollHeight &gt; oldscrollHeight){
                  $("#chatbox").animate({ scrollTop: newscrollHeight }, 'normal'); //Autoscroll to bottom of div
              }               
          },
      });
  }
  
  setInterval (loadLog, 500);
  &lt;/script&gt;
  &lt;?php
      }
      ?&gt;
      &lt;script type="text/javascript"
          src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>so i need to have post because it run in background, normal user don't see it, but here it has an edit to see it, but i don't know how to edit it to normal state.....
  Please, help me...
  thanks!</p>