title: Storing data from query in $_SESSION
body: <p>I've looked everywhere but most solutions are outdated or confusing.</p>
  
  <p>After a user's email and passwords match, their name and id are also saved then they are sent to their homepage.</p>
  
  <pre><code>  &lt;?php
  
  session_start();
  $con=mysqli_connect("localhost", "root", "", "projectinnovations");
  
  //Check connection
  if (mysqli_connect_errno())
  {
      echo "Failed to connect to MySQL:" . mysqli_connect_errno();
  }
  
  if($_SERVER["REQUEST_METHOD"] == "POST") 
  {
      $email = mysqli_real_escape_string($con,$_POST['email']);
      $password = mysqli_real_escape_string($con,$_POST['password']);
  
      $email = stripslashes($email);
      $password = stripslashes($password);
      $sql="SELECT * FROM individual_users WHERE email='$email' and password='$password'";
      $result=mysqli_query($con,$sql);
  
      $count=mysqli_num_rows($result);
  
      if ($count==1)
      {
          $_SESSION['email']= $email;
          $_SESSION['password']= $password;
          $sql1="SELECT fullname FROM individual_users WHERE email='$email' and password='$password'";
          $result1=mysqli_query($con,$sql1);
          $_SESSION['fullname']= mysqli_fetch($result1);
          $sql2="SELECT id FROM individual_users WHERE email='$email' and password='$password'";
          $result2=mysqli_query($con,$sql2);
          $_SESSION['id']= mysqli_fetch($result2);
          header("location:home.php");
      }
  
      else 
      {
          header("location:login.php");
      }
  }
   mysqli_close($con);
  ?&gt;
  </code></pre>