title: I'm not able to connect with database using jquery ajax
body: <p>I'm not able to connect with database using jquery ajax.</p>
  
  <p><strong>The below is the login1.html page</strong></p>
  
  <pre><code>    &lt;form method='POST'&gt;
                  &lt;div class="username"&gt;
                      &lt;input type="text" id='name' name="name" class="form-control" placeholder="Enter your username"&gt;
                      &lt;i class="glyphicon glyphicon-user"&gt;&lt;/i&gt;
                  &lt;/div&gt;
                  &lt;div class="password"&gt;
                      &lt;input type="password" id='password' name='password' class="form-control" placeholder="Enter your password"&gt;
                      &lt;i class="glyphicon glyphicon-lock"&gt;&lt;/i&gt;
                  &lt;/div&gt;
                  &lt;div id="error"&gt;&lt;/div&gt;
                  &lt;div class="custom-radio-checkbox"&gt;
                      &lt;input tabindex="1" type="checkbox" class="bluecheckradios"&gt;
                      &lt;label&gt;Remember me&lt;/label&gt;
                  &lt;/div&gt;
                  &lt;script&gt;
                      $(document).ready(function(){
                        $('.bluecheckradios').iCheck({
                          checkboxClass: 'icheckbox_flat-blue',
                          radioClass: 'iradio_flat-blue',
                          increaseArea: '20%' // optional
                        });
                      });     
                  &lt;/script&gt;
                  &lt;input type="submit" class="btn btn-primary style2" name='submit' id="submit" value="Sign In"&gt;
              &lt;/form&gt;
  </code></pre>
  
  <p><strong>The form value is transferred through jquery ajax</strong></p>
  
  <pre><code>&lt;script&gt;
  
  $(document).ready(function(){
  
     // jQuery methods go here...
  
  
  $('#submit').click(function(){
  
      var username = $('#name').val();
      var pass = $('#password').val();
  
      var datastring = {username:username,pass:pass};
      if($.trim(username).length&gt;0 &amp;&amp; $.trim(pass).length&gt;0){
          $.ajax({
          type: "POST",
          url : "process/login.php",
          data : datastring,
          cache: false,
          beforeSend : function(){
              $("#submit").val('Connectiing...');
          },
          success:function(data){
              if(data){
                  window.location.href('http://www.google.com');
              }
              else{
                  $('#loginone').shake();
                  $('#submit').val('Login')
                  $("#error").html("&lt;span style='color:red'&gt;Error:&lt;/span&gt;Invalid Username or Password");
              }
          }
  
          });
      }
  return false;
  
  });
  
  });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>** This is the data connection page process/login.php**</p>
  
  <pre><code>&lt;?php
  
      include_once('config.php');
  
      if(isset($_POST['submit'])){
          $username = $_POST['username'];
          $pass = $_POST['pass'];
          $sql = "select id from login where login_name = '".$username."' and login_password = '".$pass."' ";
          $result = $conn-&gt;query($sql);
          if($result-&gt;num_row &gt; 0){
  
              echo "connected";
          }
  
  
  
      }//EOF SUBMIT
  
  ?&gt;
  </code></pre>
  
  <p><strong>When ever i pass the correct credentials i get an error for wrong username and password.</strong></p>