0

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?

MvTaku Xx
  • 31
  • 4
  • 2
    yes,you need AJAX or something like that.you should always clear that php executed on server side,javascript execute on client browser side,they don't share execute context.that's the way `HTTP` working – nay Jul 14 '21 at 00:34
  • yup you need an ajax on this. – Kimchuy Jul 14 '21 at 00:39

0 Answers0