title: PHP login and session get data from databse
body: <p>This is my code in login. After login i want to userid as primary key to pass another page. i try many code but still not working. please help me     </p>
  
  <pre><code>if(isset($_POST['login']))
      {
          $email=$_POST['email'];
          $password=md5($_POST['password']);
          $sql ="SELECT * FROM tbluser WHERE EmailAddress=:email and uPassword=:password";
          $query= $dbh -&gt; prepare($sql);
          $query-&gt; bindParam(':email', $email, PDO::PARAM_STR);
          $query-&gt; bindParam(':password', $password, PDO::PARAM_STR);
          $query-&gt; execute();
          $results=$query-&gt;fetchAll(PDO::FETCH_OBJ);
          if($query-&gt;rowCount() &gt; 0)
          {
              $_SESSION['login']=$_POST['email'];
              $_SESSION['fname']=$results-&gt;FullName;
              $_SESSION['uid']=$results['UserID'];
              $currentpage=$_SERVER['REQUEST_URI'];
              echo "&lt;script type='text/javascript'&gt; document.location = '$currentpage'; &lt;/script&gt;";
          } else{
  
              echo "&lt;script&gt;alert('Invalid Details');&lt;/script&gt;";
  
          }
  
      }
  </code></pre>
  
  <p>And how to call the userid in another page.</p>