title: Redirect to the last page requested after login
body: <p>I need help regarding my login system. In my project when a user logs in they simply go to their account. If they are browsing some pages and asked to login then they should redirect to that page after login and not their profile page.</p>
  
  <p>Here is the code I am  trying for this but the user is always redirected to student_account.php and not the requested page.</p>
  
  <pre><code>$fetch = mysql_fetch_assoc($exec);
          $_SESSION['login'] = $fetch[uniq];
              $_SESSION['emailid'] = $fetch['email'];
              $emailid = $_SESSION['emailid'];
  
          $_SESSION['type'] = 'student';
          if(isset($_SESSION['url'])) 
     $url = $_SESSION['url']; // holds url for last page visited.
  else 
     $url = "student_account.php"; // default page for 
  
  header("Location:$url"); 
  </code></pre>