title: Simple login form using jquery and php
body: <p>I have got some codes from <a href="http://www.formget.com/jquery-login-form/" rel="nofollow">http://www.formget.com/jquery-login-form/</a> and implemented it.</p>
  
  <p>Below shown in the jquery file.</p>
  
  <pre><code>    $(document).ready(function()
   {
  
   $("#login").click(function()
   { 
      var username = $("#username").val();
      var password = $("#password").val();
  
  
    // Checking for blank fields.
  
      if( username =='' || password =='')
      {
          $('input[type="text"],input[type="password"]').css("border","2px solid red");
          $('input[type="text"],input[type="password"]').css("box-shadow","0 0 3px red");
          alert("Please fill all fields...!!!!!!");
      }
  
      else    
      {
  
          $.post("login.php",{ username1:username, password1:password},
          function(data) 
          {
              if(data=='Invalid Email.......')    
              {
                  $('input[type="text"]').css({"border":"2px solid red","box-shadow":"0 0 3px red"});
                  $('input[type="password"]').css({"border":"2px solid #00F5FF","box-shadow":"0 0 5px #00F5FF"});
                  alert(data);
              }
  
          else if(data=='Email or Password is wrong...!!!!')
              {
                  $('input[type="text"],input[type="password"]').css({"border":"2px solid red","box-shadow":"0 0 3px red"});
                  alert(data);
              } 
          else if(data=='Successfully Logged in...'){
                          $("form")[0].reset();
  
     $('input[type="text"],input[type="password"]').css({"border":"2px solid #00F5FF","box- shadow":"0 0 5px #00F5FF"});
    alert(data);
    } else{
    alert(data);
    }
    }); 
    }
    });
    });
  </code></pre>
  
  <p>And the php code is shown below.</p>
  
  <pre><code>     &lt;?php
          $connection = mysql_connect("localhost", "root", "12345"); // Establishing connection with server..
          $db = mysql_select_db("deve2pro", $connection); // Selecting Database.
          $username=$_POST['username1']; // Fetching Values from URL.
          $password= sha1($_POST['password1']); // Password Encryption, If you like you can also leave sha1.
          // check if e-mail address syntax is valid or not
          $username = filter_var($username, FILTER_SANITIZE_EMAIL); // sanitizing email(Remove unexpected symbol like &lt;,&gt;,?,#,!, etc.)
          if (!filter_var($username, FILTER_VALIDATE_EMAIL)){
          echo "Invalid username.......";
          }else{
          // Matching user input email and password with stored email and password in database.
          $result = mysql_query("SELECT * FROM e2pro_user WHERE User_email='$username' AND User_password='$password'");
          $data = mysql_num_rows($result);
          if($data==1){
          echo "Successfully Logged in...";
          }else{
          echo "Username or Password is wrong...!!!!";
          }
          }
          mysql_close ($connection); // Connection Closed.
          ?&gt;
  </code></pre>
  
  <p>Now the problem arise is the code is not redirected to <strong>php</strong> page from jquery.Any help appreciated.</p>