i'm trying to build a signup form there i need to check that the value of load function of ajax is true or false.
i stuck in this problem here is my code
$("button").click(function(){
$("#error").load("newEmptyPHP.php",{email:mail});
})
newEmptyPHP.php
<?php
$mail=$_POST["email"];
$db=new PDO("mysql:host=localhost;dbname=the_scops","root","");
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$STH=$db->prepare("SELECT email FROM signup WHERE email=?");
$STH->execute([$mail]);
if($STH->rowCount() == 1){
//echo "<script>$('#error').html('Email alreday exist')</script>";
return false;
}
else{
return true;
}
**
newEmptyPHP.php
you expect a response. A response has headers and a body. You can use them to provide the "result" of your operation. (i.e: with http status code, using 200 OK and 4xx).