title: I cannot get my login form to connect interact properly with mySQL database
body: <p>What I would like to happen is for a user to log in with a username and password, and if that data matches up with the one in the databse. When I try I don't get any errors, but it does not work. I am using html and php in dreamweaver, and WAM with phpMyAdmin. I will include both the form document and the php document that goes with it:</p>
  
  <p>loginpage.php</p>
  
  <pre><code> &lt;?php
  include('login.php'); // Includes Login Script
  
  if(isset($_SESSION['login_user'])){
  header("location: index.php");
  }
  ?&gt;
  
  &lt;table width="15px" border="0"&gt;
  &lt;form form action='login.php' method='POST'&gt;
  &lt;tr&gt;
  &lt;td&gt;Username&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="username" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Password&lt;/td&gt;
  &lt;td&gt;&lt;input type="password" name="password" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;input type="submit" name="submit" value="submit"/&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>
   </p>
  
  <p>login.php</p>
  
  <pre><code>  &lt;html&gt;
     &lt;head&gt;
      &lt;title&gt;Login&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
    &lt;?php 
      session_start(); // Starting Session
      $error=''; // Variable To Store Error Message
      if (isset($_POST['submit'])) {
      if (empty($_POST['username']) || empty($_POST['password'])) {
      $error = "Username or Password is invalid";
      }
      else
      {
      // Define $username and $password
      $username=$_POST['username'];
      $password=$_POST['password'];
      // Establishing Connection with Server by passing server_name, user_id   and password as a parameter
      $hostname= "localhost";
      $database = "boost";
      $username = "root";
      $password = "";
      $localhost = mysqli_connect($hostname, $username, $password, $database);
      if(mysqli_connect_errno())
      {
          die("Connection Failed".mysqli_error());
      }
      // SQL query to fetch information of registerd users and finds user match.
      $sql = "SELECT * FROM `users`";
      $query = mysqli_query($localhost,$sql);
      if(!$query)
      {
          die("Query Failed".mysqli_error($localhost));
      }
      $rows = mysqli_num_rows($query);
      if ($rows == 1) {
      $_SESSION['login_user']=$username; // Initializing Session
      echo "You are now logged on!";
      } else {
      $error = "Username or Password is invalid";
      }
      mysqli_close($localhost); // Closing Connection
      }
      }
    ?&gt;
   &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>