title: Use Of Undefined Constant in script
body: <p>I've searched the site and saw fixes for the issue in which the user should have put single quotes around the variable but I still a bit confused.</p>
  
  <p>Errors: (all refer to line 28)
  Notice: Use of undefined constant log_id - assumed 'log_id' 
  Notice: Use of undefined constant log_username - assumed 'log_username'
  Notice: Use of undefined constant log_password - assumed 'log_password' </p>
  
  <p>Script:</p>
  
  <pre><code>     &lt;?php
        session_start();
  
  include ("includes/connection.php");
  
  $user_ok = false;
  $log_id = "";
  $log_username = "";
  $log_password ="";
  
  
  function evalLoggedUser($con,$id,$u,$p){
      $sql = "SELECT ip FROM users WHERE id='$id' AND username='$u' AND password='$p' AND activated='1' LIMIT 1";
      $query = mysqli_query($con, $sql);
      $numrows = mysqli_num_rows($query);
      if($numrows &gt; 0){
          return true;
      }
  }
  
  if(isset($_SESSION["userid"]) &amp;&amp; isset($_SESSION["username"]) &amp;&amp; isset($_SESSION["password"])) {
      $log_id = preg_replace('#[^0-9]#', '',$_SESSION['userid']);
      $log_username = preg_replace('#[^a-z0-9]#i','', $_SESSION ['username']);
      $log_password = preg_replace('#[^a-z0-9]#i','', $_SESSION ['password']);
  
      //VERIFY USER
  
      $user_ok = evalLoggedUser($con,log_id,log_username,log_password);
  
  } else if(isset($_COOKIE["id"]) &amp;&amp; isset($_COOKIE["user"]) &amp;&amp;  isset($_COOKIE["pass"])) {
      $_SESSION['userid'] =  preg_replace('#[^0-9]#', '',$_COOKIE['userid']);
      $_SESSION ['username'] =preg_replace('#[^a-z0-9]#i','', $_COOKIE ['username']);
      $_SESSION['password'] =  preg_replace('#[^a-z0-9]#i','', $_COOKIE ['username']);
  
      //CREATE LOCAL SHORT VARIABLES
  
      $log_id = $_SESSION['userid'];
      $log_username = $_SESSION['username'];
      $log_password = $_SESSION['password'];
  
      if($user_ok == true){}
      //UPDATE LAST LOGIN TIME
      $sql = "UPDATE users SET lastlogin=now() WHERE id='$log_id' LIMIT 1";
      $query = mysqli_query($con,$sql);
  }
  
  
  ?&gt;
  </code></pre>