php - JQuery Bassistance Form Email-check using remote -


i'm using jquery bassistance form validation plugin, , works fine until try check existing e-mails in mysql database.

here code:

    $(document).ready(function(){     $('#signup').validate({     rules: {             email: {             required: true,         email: true,         remote: {             type: 'post',             url: "email_check.php"         }//end remote         }//end email     },//end rules     messages: {         email: {             remote: "email in use."         }//end email     } //end messages     }); //end validate      }); //end ready 

and here email_check.php file:

    <? php      $dbc = mysqli_connect('localhost', 'root', '', 'step1_db')     or die('error connecting database');      $email = $_get['email'];      $check_email = "select * users email = '$email'";     $existing = mysqli_query($dbc, $check_email);     $num_rows = $existing->num_rows;          if ($num_rows == 1){     echo json_encode(false);      }else{      echo json_encode(true);     }      mysqli_close($dbc);      ?> 

so right now, if try input e-mail exists in database form, default error message invalid e-mail, , not "email in use." if input valid e-mail not exist in database, error message doesn't go away.

i'm guessing problem in php file... i've tried using 'return true' , 'return false' did not work. changed code echo json_encode(false) answers similar topics one. able put finger on what's going on here?

from documentation:

the serverside resource called via $.ajax (xmlhttprequest) , gets key/value pair, corresponding name of validated element , value parameter. response evaluated json , must true valid elements, , can false, undefined or null invalid elements, using default message; or string, eg. "that name taken, try peter123 instead" display error message.

it looks responding correctly. looks path file wrong since getting 404 error in console. fix path , rest looks good.


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -