title: Unable to navigate to another page using PHP, MySQL
body: <p>I have some data in the database. As i give the email and password it should fetch the database and login. The problem is, from loginform.php file it is navigating to the loginvalidate.php file, but after that it doesn't navigate to another page which I have mentioned in the header() function. As soon as i give the email and password, and hit the login button, it just stops at loginvalidate.php and doesn't proceed to profile.php file. I hope you get it.I donno where the error is, it is neither throwing an error. I'm using WAMP and when I run this code in the browser, the url should display ../../profile.php after hitting the login button, but it shows ../../loginvalidate.php in the URL and the page has nothing to show i.e blank. I have used the md5 function to store passwords in the database. So here also first I have applied the md5  function on the user entered password and then used the password_verify. Is it the password verifying problem or is it anything else ?</p>
  
  <p><strong>loginform.php</strong></p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
      &lt;link rel="stylesheet" type="text/css" href="css/style.css"&gt;
      &lt;script type="text/javascript" src="js/jquery.validate.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;form action="includes/loginvalidate.php" method="post"&gt;
          &lt;div style="margin-top:17%;"&gt;
           &lt;!--Text box to enter email-id--&gt;
              &lt;input id="email" type="email" name="eid" placeholder="E-mail" required/&gt;
              &lt;hr style="position:relative; color:white;"&gt;
          &lt;/div&gt;
          &lt;div style="margin-top:3%"&gt;
           &lt;!--Text box to enter password--&gt;
              &lt;input id="pwd" type="password" name="password" placeholder="Password" required/&gt;
          &lt;/div&gt;  
              &lt;div style="margin-top:15%"&gt;
                  &lt;input type="image" class="mclass" name="loginbt" id="login"  src="images/login.png"&gt;
              &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>includes/loginvalidate.php</strong></p>
  
  <pre><code>&lt;?php
  session_start();
  try
  {
      $db = new PDO("mysql:host=localhost;dbname=xxx","yyy","zzz");
      $db-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      if(isset($_POST['loginbt']))
      {
          $errmsg='';
          $email =$_POST['eid'];
          $pass = md5($_POST['password']);
  
          if($errmsg == '')
          {
              $sql = $db-&gt;prepare('SELECT id, email, password from users WHERE email = :email');
              $sql-&gt;bindParam(':email',$email);
              $sql-&gt;execute();
              $result = $sql-&gt;fetch(PDO::FETCH_ASSOC);
              if(count($result)&gt;0 &amp;&amp; password_verify($pass,$result['password']))
              {
                  header('location: ../profile.php');
                  exit();
              }
              else
              {
                  echo '&lt;script language="javascript"&gt;';
                  echo 'alert("Username/Password is incorrect")';
                  echo '&lt;/script&gt;';
              }
          }
      }
  }
  catch(PDOException $e)
  {
      echo $e-&gt;getMessage();
  }       
  </code></pre>
  
  <p>?></p>