I'm trying to correct a login/sign up issue i'm having, and having trouble. I've included a jsfiddle with the code, but im not sure what I'm missing.
https://jsfiddle.net/Zemanor/fuzrkw16/1/
I am consistently able to insert users into the correct db table on submit, but it gives the "You have already created an account!" alert and inserts the info, even if the account is not in the table pre-submit. I want to reject the account if there is one in the database, or accept it if it doesn't currently exist. How do I correct this problem? (php incl in jsfiddle)
//signup js
$(document).ready(function(){ var url="http://localhost/auth.php";
$("#signup").click(function(){
var fullname=$("#fullname").val();
var email=$("#email").val();
var password=$("#password").val();
var dataString="fullname="+fullname+"&email="+email+"&password="+password+"&signup=";
if($.trim(fullname).length>0 & $.trim(email).length>0 & $.trim(password).length>0)
{
$.ajax({
type: "POST",
url: url,
data: dataString,
crossDomain: true,
cache: false,
beforeSend: function(){ $("#signup").val('Connecting...');},
success: function(data){
if(data=="success")
{
alert("Thank you for registering with us! you can login now");
}
else if(data="exist")
{
alert("You already created an account!");
}
else if(data="failed")
{
alert("Something Went wrong");
}
}
});
}return false;
});