The login still continues even when the username is not valid
<p>I have the following code bellow that will check to see if the user is available in the database before he is granted access to the site however when the user enters any value it will log him in even if he is not registered in the data base. After this code there is JQuery code that i also used to prevent any value from being enterd into that database if the field is empty and it is not the default text field value. however whenever the i login i am still begin prompt to enter a valid text and it continues to the login process rather then stopping me from doing anything before i fill the required field.</p>

<pre><code>&lt;?php 
    if(isset($_SESSION["owner"])){
        header("Location:index.php");
        exit();
    }
?&gt;
&lt;?php
    require_once("includes/connection.php");
    if(isset($_POST["username"]) &amp;&amp; isset($_POST["password"])){
        $owner = $_POST["username"];
        $password = $_POST["password"];
        $query = "SELECT id FROM users WHERE username = '$owner' AND password ='$password' LIMIT 1";
        $sql = mysql_query($query,$connection);
        $existCount = mysql_num_rows($sql);
        if($existCount == 1){   
            while($row = mysql_fetch_array($sql)){
                $id = $row["id"];
            }
            $_SESSION["id"] =$id;
            $_SESSION["owner"] = $owner; 
            $_SESSION["password"] =$password;
            echo"welcome back" .$owner."&lt;a href=\"index.php\"&gt; please continue&lt;/a&gt;";
            exit();
        }
        else{
            header("Location:login.php");
            exit();
        }
    }
    require_once("includes/header.php");
?&gt;
&lt;script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js?ver=3.2.1'&gt;&lt;/script&gt;
&lt;script type='text/javascript' src='/bobs/admin/javascript/login.js'&gt;&lt;/script&gt;
&lt;div class="cBoth"&gt;&lt;/div&gt;
&lt;div id="sep"&gt;&lt;/div&gt;

&lt;div class="Calign"&gt;
&lt;div id="formcontent"&gt;

&lt;div class="flotr"&gt;
 &lt;h2&gt;Book faster every time&lt;/h2&gt; 
 &lt;br/&gt;
 &lt;p class="widthis"&gt;Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source.&lt;/p&gt;
&lt;/div&gt;&lt;!-- end of flotr div text ---&gt;

&lt;div class="flotr"&gt;
&lt;div id="errordisplay"&gt;&lt;/div&gt;
   &lt;fieldset class="spacing"&gt;
   &lt;form method="post" action="admin/formProc/formproc.php" id="frmnewuser"&gt;
     &lt;h2&gt;New to Travelnstay ?&lt;/h2&gt;
     &lt;p class="widthis"&gt;A Travelnstay account is required to continue.&lt;/p&gt; 
     &lt;p class="formsp"&gt;Username&lt;/p&gt;
     &lt;p&gt;&lt;label&gt;&lt;input type="text" name="username" height="15px"  value="Username "id="username"/&gt;&lt;label&gt;&lt;/p&gt;
     &lt;p class="formsp"&gt;Email&lt;/p&gt;
     &lt;p&gt;&lt;label&gt;&lt;input type="text" name="email" value="Your Email" id="email"/&gt;&lt;label&gt;&lt;/p&gt;
     &lt;p class="formsp"&gt;Re-email&lt;/p&gt;
     &lt;p&gt;&lt;label&gt;&lt;input type="text" name="reemail" value="Retype your Email"  id="reemail"/&gt;&lt;label&gt;&lt;/p&gt;
     &lt;p class="formsp"&gt;Password&lt;/p&gt; 
     &lt;p&gt;&lt;label&gt;&lt;input type="password" name="password" id="password"/&gt;&lt;label&gt;&lt;/p&gt;
     &lt;p class="formsp"&gt;Re-password&lt;/p&gt;
     &lt;p&gt;&lt;label&gt;&lt;input type="password" name="repassword" id="repassword" /&gt;&lt;label&gt;&lt;/p&gt;
     &lt;p class="formsp"&gt;&lt;label&gt;&lt;input type="submit" name="newuser" value="SING ME UP"/&gt;&lt;label&gt;&lt;/p&gt;
   &lt;/form&gt;
  &lt;/fieldset&gt;
&lt;/div&gt;&lt;!-- end of flotr div sign up---&gt;




&lt;div class="flotl"&gt;
   &lt;fieldset class="spacing"&gt;
   &lt;form method="post" action="login.php"&gt;
   &lt;h2&gt;Sign in&lt;/h2&gt;
   &lt;p class="widthis"&gt;You need to log in to access your account.&lt;/p&gt; 
   &lt;p class="formsp"&gt;Username&lt;/p&gt;
   &lt;p&gt;&lt;input type="text" name="username"  value="username" id="usernamelog"/&gt;&lt;/p&gt;
   &lt;p class="formsp"&gt;Password&lt;/p&gt;
   &lt;p&gt;&lt;input type="password" name="password"  /&gt;&lt;/p&gt;
   &lt;p&gt;&lt;/p&gt;
   &lt;p class="formsp"&gt;&lt;label&gt;&lt;input type="submit" name="login" value="Login"/&gt;&lt;label&gt;&lt;/p&gt;   
   &lt;/form&gt;
   &lt;/fieldset&gt;
&lt;/div&gt;&lt;!-- end of flotl div login---&gt;


 &lt;/div&gt;
&lt;/div&gt;


&lt;div class="cBoth"&gt;&lt;!-- clear Both--&gt;&lt;/div&gt; 
&lt;!--&lt;script src="/bobs/admin/javascript/formscript.js"&gt;&lt;/script&gt;--&gt;
&lt;?php require_once("includes/footer.php"); ?&gt;
</code></pre>

<p>The next line is the JQuery code.</p>

<pre><code>$(document).ready(function(){
    //this will waip out anyhting in that text field.    
    $("#usernamelog").click(function(){
        $(this).val("");
        $(this).css("color","#741863");
    });          
    $("input:submit").click(function(){
        var username = $("#usernamelog").val();            
        if((username == "")||(username == "username")){
           alert("Please enter a valid username");
        }          
    });
});
</code></pre>
