title: PHP login validation on the same page?
body: <p>Could anyone explain me how to check and register username and password in the same page?</p>
  
  <p>How can I echo the "wrong username and password" message in the form?</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>Check Login</strong></p>
  
  <pre><code>$result=mysql_query($sql);
  $count=mysql_num_rows($result);
  
  // If result matched $myusername and $mypassword, table row must be 1 row
  if($count==1){
    // Register $myusername, $mypassword and redirect to file "login_success.php"
    session_register("myusername");
    session_register("mypassword");
    header("location:login_success.php");
  }
  else {
    echo "Wrong Username or Password";
  </code></pre>
  
  <p><strong>FORM</strong></p>
  
  <pre><code>&lt;form class="clearfix" name="form1" method="POST" action=""&gt;
  </code></pre>