I've been tinkering on this for a while, any good samaritan may please help without cursing on the silliness of my problem. I would like the following ajax login function to return true if the posted input is present, here is my code php:
$cell = $_POST['cell'];
$link = mysqli_connect("localhost", "user", "pass", "db");
$query = "SELECT * FROM snoopers WHERE cell='$cell ' LIMIT 1";
$result = mysqli_query($link, $query)or die(mysqli_error());
$num_row = mysqli_num_rows($result);
$row=mysqli_fetch_array($result);
if( $num_row >0 ) {
echo 'true';
}
else{
echo 'false';
}
mysqli_close($link);
and below is the front
//Login
$("#login").click(function(e){
e.preventDefault();
$.ajax({
type: "POST",
url: "http://localhost/sc/new/lib/login.php",
datatype:"application/json",
data: {
cell: $("#cell").val()
},
timeout: 6000,
success: function(html)
{
$("#result").html(html).show();
},
//success: function(html){ if(html=='true') { alert("True"); }else{alert("you are a failure");}},
beforeSend:function(){
//$("body").html("Loading...")
},
complete:function(){
}
});
}); return false;
});