Couldn't get response from database with jQuery using PHP post request -


i cannot script work. try warn if login user entered available. cannot manage script work:

$( "#myregform" ).submit(function( event ) {      var errors = false;     var useravi = true;     var logininput = $('#login').val();      if( logininput == ""){         $("#errorarea").text('login cannot empty!');         $("#errorarea").fadeout('15000', function() { });         $("#errorarea").fadein('15000', function() { });          errors = true;     }     else if(logininput.length < 5 ){         $("#errorarea").text('login must @ least 5 characters!');         $("#errorarea").fadeout('15000', function() { });         $("#errorarea").fadein('15000', function() { });         errors = true;     }     else if (logininput.length >=5) {         $.post('checklogin.php', {login2: logininput}, function(result) {              if(result == "0") {                 alert("this");                           }             else {                 alert("that");             }         });                     }      if (errors==true) {         return false;     } }); 

everything works fine until logininput.length >=5 else block. assume there problem getting answer php file, cannot handle it, though tried many different ways. here checklogin.php's file (note jquery script , php file in same folder):

<?php include ("bd.php");  $login2 = mysql_real_escape_string($_post['login2']);  $result = mysql_query("select login users login='$login2'");  if(mysql_num_rows($result)>0){       //and send 0 ajax request       echo 0;      }     else{       //else if it's not bigger 0, it's available '       //and send 1 ajax request       echo 1;   }    ?> 

<?php include ("bd.php");  $login2 = mysql_real_escape_string($_post['login2']);  $result = mysql_query("select login users login='$login2'");  if(mysql_num_rows($result)>0){       //and send 0 ajax request       echo "0"; // use if(if(result == "0") should send string     } else {     //else if it's not bigger 0, it's available '     //and send 1 ajax request     echo "1";   

} ?>


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -