In order to verify if the user's email is legit or not, I created a PHP script that sends a code to the email targeted and then shows an input dialog for the user to write it.
I used Javascript and PHP.
//sending mail script
echo '
<script>
swal({
title: "Are you sure?",
text: "Once deleted, you will not be able to recover this imaginary file!",
icon: "success",
content: "input"
}).then((input) => {
if (input=='. $codeNumber .') {
' . '$stmtinsert = $db->prepare($sql);
$result = $stmtinsert->execute([$username, $email, $phone_number, $birthday, $hashed_password]);'
. '
swal({
titre: "Registred successfully!",
icon: "success"
text: "Your account has been created, now you can Log in.";
});
} else {
swal("sir thawa code ghalat");
}
});
</script>
';
I don't know how to run the php code if the conditions are true in javascript. Do i need to use AJAX or something other than this methode?