title: javascript and php - login script
body: <p>I am begginer in programming, I commented the rows, where I dont understand the code.
  And the connection to database is ok, so I do not understand why it is not working.</p>
  
  <p>HERE IS LOGIN.PHP</p>
  
  <pre><code>&lt;?php
  
  include("connectiondbs.php");
  include("javascript.js");
  session_start();
  if($_SERVER["REQUEST_METHOD"] == "POST")
  {
  $u=$_POST['username'];
  $p=$_POST['password'];
  
  $sql="SELECT userID FROM users WHERE login='$u' and password='$p'";
  $result=mysql_query($sql);
  $row=mysql_fetch_array($result);
  
  $active=$row['active'];            //I AM NOT SURE ABOUT THIS ONE
  
  $count=mysql_num_rows($result);
  
  if($count==1)
  {
  session_register("username");
  session_register("password");     //HAS TO BE THE PASSWORD IN REGISTER?
  $_SESSION['login_user']=$u;
  
  header("location:succesfulllogin.php");  // HAS TO BE THIS FILE? OR I CAN GO TO THE MENU.HTML RIGHT NOW
  
  }
  else {
  echo "Wrong Username or Password";
  }}
  ?&gt;
  
  &lt;form action="" method="post"&gt;
  &lt;label&gt;Login :&lt;/label&gt;
  &lt;input type="text" name="username"/&gt;&lt;br /&gt;
  &lt;label&gt;Password :&lt;/label&gt;
  &lt;input type="password" name="password"/&gt;&lt;br/&gt;
  &lt;input type="submit" value=" Submit "/&gt;&lt;br /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>JAVASCRIPT.JS</p>
  
  <pre><code>&lt;script Language="JavaScript"&gt;
      &lt;!-- 
          function check_empty_field()
          {
          if (form.username.value == "" || form.password.value == "")
          {
             alert("Please fill in the password or login field.");
             return (false);
          }
          return (true);
          }
          --&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>succesfulllogin.php</p>
  
  <pre><code>&lt;?php
  session_start();
  if(!session_is_registered(username)){
  header("location:login.php");
  }
  else{
  header ("location:menu.html");
  }
  ?&gt;
  </code></pre>