title: PHP - Login form
body: <p>I am new to PHP, I created a login form and home page. I followed the same it is said in the tutorials, but I keep getting the error as 'wrong details' though i provided the right credentials. </p>
  
  <p>// login page</p>
  
  <pre><code>    **Login.php**
  
          &lt;?php
          session_start();
          include_once 'database1.php';
  
          if(isset($_SESSION['user'])!="")
          {
           header("Location: index1.php");
          }
          if(isset($_POST['login']))
          {
           $email = mysql_real_escape_string($_POST['email']);
           $pass = mysql_real_escape_string($_POST['password']);
           $result=mysql_query("SELECT * FROM users WHERE email='$email'");
           $row=mysql_fetch_array($result);
           if($row['password']==md5($pass))
           {
            $_SESSION['user'] = $row['number'];
            header("Location: index1.php");
            ?&gt;
          &lt;script&gt; alert ('haii'); &lt;/script&gt;
          &lt;?php
           }
           else
           {
            ?&gt;
                  &lt;script&gt;alert('wrong details');&lt;/script&gt;
                  &lt;?php
           }
  
          }
          ?&gt;
        &lt;html&gt;
  
  
      &lt;body&gt;
  
  
              &lt;form  method="post" &gt;
           &lt;label&gt;&lt;center&gt;EMAIL&lt;/center&gt; &lt;input type="text" name="email" placeholder="Your Email" required /&gt; &lt;/label&gt; &lt;/br&gt;
  
           &lt;label&gt;PASSWORD &lt;input type="password" name="password" placeholder="Your Password" required /&gt;&lt;/label&gt; &lt;/br&gt;
  
  
      &lt;button type="submit" name="login"&gt;login&lt;/button&gt; &lt;/br&gt;
      &lt;/br&gt;
  
      &lt;/form&gt;    
  
      &lt;/html&gt;
  </code></pre>
  
  <p>// index page</p>
  
  <pre><code>**index1.php**
  
  &lt;?php
  session_start();
  include_once 'database1.php';
  
  if(!isset($_SESSION['user']))
  {
   header("Location: login.php");
  }
  $result=mysql_query("SELECT * FROM users WHERE number=".$_SESSION['user']);
  $userRow=mysql_fetch_array($result);
  ?&gt;
  &lt;html&gt;
  &lt;body&gt;
  &lt;p&gt; welcome &lt;/p&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>