I use the following method to call php:
function validateEmaiAjax(email){
val = null;
$("#warning").load("https://localhost/Continental%20Tourism/register_ajax.php",{email: email}, function(rspns, stat, xml){
val = rspns;
});
if(val == ".")
return true;
else {
return false;
}
}
my php code is:
<?php
$dbc = mysqli_connect("localhost","root","pass","continental_tourism") OR die(mysqli_connect_error());
$email = $_REQUEST['email'];
$query = "SELECT email FROM customer_info WHERE email = '$email' ";
$r = mysqli_query($dbc, $query) OR die(mysqli_error($dbc));
if(mysqli_num_rows($r) > 0)
echo "Email address exists!";
else
echo ".";
?>
This basically checks the database, and if the email exists, "Email address exists!" if not, I want return true(so I echo "." and compare it). It is strange if I set a breakpoint using firebug next to the program if(val == "."), it works correctly and returns true. If I remove this breakpoint function, always return false. I can’t understand why this is happening. Please help! Thank.
source
share