login form php with jquery validation
<p>hello I am new here and in programming as well. Today I have been made a login form in php / mysql and jquery form validation and was surprised that my form do not work bacause of js script? withou work well.</p>

<pre><code>&lt;div class="top_login_error" id="top_error"&gt;All fields must be field&lt;/div&gt;
    &lt;div id="logincontainer"&gt;
        &lt;div id="loginbox"&gt;
            &lt;div id="loginheader"&gt;
                &lt;div&gt;Control Panel Login&lt;/div&gt;
            &lt;/div&gt;
            &lt;div id="innerlogin"&gt;
                &lt;form method="POST" action="obr.php" id="login_form"&gt;
                    &lt;p&gt;Enter your username:&lt;/p&gt;
                    &lt;input type="text" class="logininput" name="login" id="login" /&gt;
                    &lt;p&gt;Enter your password:&lt;/p&gt;
                    &lt;input type="password" class="logininput" name="password" id="password" /&gt;
                    &lt;input type="submit" class="loginbtn" value="Submit" name="enter" id="admin_login" /&gt;&lt;br /&gt;
                    &lt;p&gt;&lt;a href="#" title="Forgoteen Password?"&gt;Forgotten Password?&lt;/a&gt;&lt;/p&gt;
                &lt;/form&gt;
            &lt;/div&gt;
        &lt;/div&gt;
        &lt;img SRC="../images/administration/login_fade.png" alt="Fade" /&gt;
    &lt;/div&gt;
&lt;/body&gt;
</code></pre>

<p>jquery ccode for validating form</p>

<pre><code>$('#admin_login').click(function(q){

q.preventDefault();

    var login = $('#login').val();
    var password = $('#password').val();

    if (login.length == 0){
        $('#top_error').fadeIn(500);
        $('#login').addClass("logininput_error");
        var error = true;
    } else {
        $('#top_error').fadeOut(500);
        $('#login').removeClass("logininput_error");
        }
    if (password.length == 0){
        $('#top_error').fadeIn(500);
        $('#password').addClass("logininput_error");
        var error = true;
    } else {
        $('#top_error').fadeOut(500);
        $('#password').removeClass("logininput_error");
        }

});
</code></pre>

<p>and php</p>

<pre><code>&lt;?php 
session_start(); 



    if (isset($_POST['login'])){$login = $_POST['login'];} if ($login == ''){unset($login); exit('please enter name');}
    if (isset($_POST['password'])){$password = $_POST['password'];} if ($password == ''){unset($password); exit('please enter password');}

    $login = mysql_escape_string($_POST['login']);
    $password = mysql_escape_string($_POST['password']);

    //$password = md5($password); I have been disabled while testing in simle way, login : aaa , password : aaa;

    include("../db.php");

    $result = mysql_query("SELECT * FROM users WHERE login='".$login."' and password='".$password."'") or die(mysql_error());

    $line = mysql_fetch_array($result);

    if (empty($line['id'])){
        exit("Your name or login is incorect &lt;a href='login.php'&gt;back&lt;/a&gt;");
    } else {

    $_SESSION['autorized'] = true;
    $_SESSION['login'] = $login;
    $_SESSION['password'] = $password;
    }
    echo "&lt;html&gt;&lt;head&gt;&lt;meta http-equiv='Refresh' content='0; URL=index.php'&gt;&lt;/head&gt;&lt;/html&gt;";

?&gt;
</code></pre>

<p>Can someone help me with code, tell what to change that everything work fine. Thank you</p>
