title: Get specific data from database with PHP code when a user login
body: <p>I want to get data from my database with PHP code. In brief when a user log in with id &amp; password i want to show his data only in user panel, but i got some error: Here is my user admin panel code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;link rel="stylesheet" type="text/css" href="css/style.css"&gt;
  
      &lt;meta charset="utf-8"&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;title&gt;User Panel&lt;/title&gt;
      &lt;link rel="stylesheet" href="assets/demo.css"&gt;
      &lt;link rel="stylesheet" href="assets/form-labels-on-top.css"&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
      &lt;header&gt;
          &lt;h1 align="center"&gt;&lt;b&gt;User Information Details&lt;/b&gt;&lt;/h1&gt;&lt;/br&gt;    
      &lt;/header&gt;
  
  
  
  
      &lt;?php
  
              $servername = "localhost";
              $username = "root";
              $password = "";
              $dbname = "xyz";
  
              // Create connection
              $conn = new mysqli($servername, $username, $password, $dbname);
              // Check connection
              if ($conn-&gt;connect_error) 
              {
                  die("Connection failed: " . $conn-&gt;connect_error);
              } 
  
              include('user_login_check.php');
  
  
              $result= mysql_query("SELECT * FROM `user_information` WHERE `user_id` = '".$_SESSION['id']."' ")or die(mysql_error());
  
  
  
  
  
      //  $result = mysql_query("SELECT * FROM user_information WHERE user_name='" . $_POST["user_name"] . "' and user_password = '". $_POST["user_password"]."'");
  
      ?&gt;  
  
  &lt;form&gt;
  &lt;table border="5" style= "background-color: #333333; color: #FFF; margin: 0 auto; padding:100px" &gt;
  &lt;thead&gt;
  &lt;tr&gt;
  &lt;th&gt;User ID&lt;/th&gt;
    &lt;th&gt;User Type&lt;/th&gt;
    &lt;th&gt;User Name&lt;/th&gt;
    &lt;th&gt;User Country&lt;/th&gt;
    &lt;th&gt;User Email&lt;/th&gt;
    &lt;th&gt;User Phone&lt;/th&gt;
    &lt;td&gt;User Address&lt;/td&gt;
    &lt;td&gt;User Password&lt;/td&gt;
    &lt;td&gt;User Status&lt;/td&gt;
    &lt;td&gt;Edit&lt;/td&gt;
  
  &lt;/tr&gt;
  &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;?php
  
            while( $row = mysqli_fetch_assoc( $result ) ){
              echo
              "&lt;tr&gt;
                &lt;td&gt;{$row['user_id']}&lt;/td&gt;
                &lt;td&gt;{$row['user_type']}&lt;/td&gt;
                &lt;td&gt;{$row['user_name']}&lt;/td&gt;
                &lt;td&gt;{$row['user_country']}&lt;/td&gt;
                &lt;td&gt;{$row['user_email']}&lt;/td&gt;
                &lt;td&gt;{$row['user_phone']}&lt;/td&gt;
                &lt;td&gt;{$row['user_address']}&lt;/td&gt; 
                &lt;td&gt;{$row['user_password']}&lt;/td&gt; 
                &lt;td&gt;{$row['user_status']}&lt;/td&gt;
                &lt;td&gt;&lt;a href=\"edit.php?id={$row['user_id']}\"&gt;&lt;img src='image/editicon.jpeg'/&gt;&lt;/a&gt;&lt;/td&gt;;
  
              &lt;/tr&gt;\n";
  
  
  
            }
          ?&gt;
  
  
  
      &lt;/tbody&gt;
      &lt;div align="left" style="background:#333333"&gt;
      &lt;h1&gt;&lt;input type="button" value="Log Out" onClick="window.location.href='logout_user.php'" /&gt;    &lt;/h1&gt;
  &lt;/div&gt;
   &lt;/table&gt;
  &lt;/form&gt;             
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>problem is in specially this section</p>
  
  <pre><code>$result= mysql_query("SELECT * FROM `user_information` WHERE `user_id` = '".$_SESSION['id']."' ")or die(mysql_error());
  </code></pre>
  
  <p>here is my login check code:</p>
  
  <pre><code>&lt;?php
   //connect the database
  $hostName="localhost";
  $dbUsername="root";
  $dbPassword="";
  $dbName="xyz";
  mysql_connect($hostName,$dbUsername,$dbPassword) or die("Connection failed");
  mysql_select_db($dbName) or die("Database name doesn't exist");
  
  //start session
  @session_start();
  
  if(isset($_POST["user_name"] , $_POST["user_password"])) 
          {     
             $User_name = $_POST["user_name"]; 
            // echo "$User_name";
             $User_password = $_POST["user_password"]; 
           //  echo "$User_password";
              $sql = "SELECT * FROM `user_information` WHERE `user_name`='".$User_name."' AND `user_password`='".$User_password."' ";
              $result = mysql_query($sql) or trigger_error(mysql_error().$sql);        
              // $result = mysql_query("SELECT * FROM `user_info` WHERE `User_name`='".$username."' AND `User_password``='".$password."'");
  
              $my_arary = array();
              while($row = mysql_fetch_assoc($result))
                  {
                      $_SESSION['id']= $row["Id"];
                  //  echo $_SESSION['login_user_id'];
                      $_SESSION['user_password']= $row["user_password"];
                      //echo $_SESSION['login_user_password'];
                      $_SESSION['user_name']= $row["user_name"];
                      //echo $_SESSION['login_user_name'];
  
  
                      $my_arary[] = $row;
                      print_r($row);
  
                      if($User_name == $_SESSION['user_name'] &amp;&amp; $User_password == $_SESSION['user_password']){
                      header("Location: userpanel.php"); 
                      //echo "successfully logged in";
                      }
  
                      else{
                      echo "no matches";
                       header("Location: user_login_basic.php");
                      }
  
                  }
          } 
  ?&gt;
  </code></pre>