My main aim of the project is to provide user authentication and redirect them into their respective web services. Firstly I've created HTML page containing login form. So when the users enter their data, I retrieve the password and email information from the database, if data entered is correct, then I should redirect them to another PHP page. So my problem comes here.... I'm using PHP headers to redirect them to another page, everything is fine with HTML and MySQL database and the users are entering the form data and are accessing their web pages. But if the users are trying to get back to the original page, it is being redirected to the page mentioned in the header!! The user is not able to access the original form page.I used the function with in HTML tags.I didn't mention any action in the form. If the user enters either a wrong email id or wrong password, then the function displays the error msg in the same form page itself, but if he enters the correct data, he will be directed to the page in the header location. So when the user wishes to get back to form page or restarts the original page after some, it is being redirected to header location. So when I'm removing the header location, and reload it I'm able to see the original page. Can anyone help me to correct the code?

```
<?php
function check_username($eid_login,$pwd_login)
{
 $servername="Localhost";
 $username="root";
 $password="2537@Nuka";
 $dbname="Secure_Drive";
 $conn=mysqli_connect($servername,$username,$password,$dbname);
 if(!$conn)
 {
  #die("Couldn't to connect to database:".mysqli_connect_error());
 }
 else
 {
  #echo "Connected sucessfully to the database";
 }
 $sql="SELECT * FROM SignUp_Info WHERE Email_Id='$eid_login'";
 $result=mysqli_query($conn_db_login,$sql);
 if(mysqli_num_rows($result)>0)
 {
  while($row=mysqli_fetch_assoc($result))
  {
   $verify_login_pwd=$row["Password"];
   if($pwd_login!=$verify_login_pwd)
   {
    $password_match="You entered wrong password";
    echo "<p class=\"php\">".$password_match."</p>";
   }
   else
   {
    header('Location:sample.php');
   }
  }
 }
 else
 {
  $email_exits="Id does not exists";
  echo "<p class=\"php\">".$email_exits."</p>";
 }
}
?>
<html>
<head>
  <title>
   Login-Home
  </title>
  <link rel="stylesheet" type="text/css" href="css/login.css">
</head>
<body>
 <header>
  <div class="name">
    <a href="#"><h1>Secure Drive</h1></a>
  </div>
 </header>
 <main>
   <div>
    <center>
    <form method="POST">
      <fieldset class="formstyle">
        <legend>Login</legend>
          <div class="adjust">
            <br><label class="labels">E-mail ID</label><br>
            <input class="floattype" type="text" name="emailid_login" placeholder="E-mail Id" required><br>
            <br><label class="labels">Password</label><br>
            <input class="floattype" type="password" name="password_login" placeholder="Password" required><br>
            <br><button type="submit" value="Login">Login</button>
          </div>
      </fieldset>
    </form>
    <?php 
     $eid_login=$_POST["emailid_login"];
     $pwd_login=$_POST["password_login"];  
     check_username($eid_login,$pwd_login); ?>
    <br><br><a class="link" href="signup.php">Click here to SignUp</a>
    </center>
   </div>
  </main>
 <footer>
  <p>&copy;2016 Secure Drive,Gryffindors Inc.</p>
 </footer>
</body>
</html>

```