sashavalentina Posted March 15, 2022 Share Posted March 15, 2022 I'm using sweet alert to send the user a warning message that show to them that the information insert is not valid in PHP echo. I want the "okay" button link to the desire page but it just could not work. my developer console shows the error of login.php:29 Uncaught TypeError: Cannot read properties of undefined (reading 'then') but I have no idea how can I make this work. I spent hours searching here and there but it just don't. Anyone who lend me a helping hand will be truly appreciated. Thanks. Below are my codes: if (isset($_POST['login'])) { $email = $_POST['email']; $user_password = $_POST['user_password']; $sql = "SELECT * FROM users WHERE user_phone = '$email' OR username = '$email' "; $query = $conn->query($sql); if ($query->num_rows < 1) { echo '<script> swal({ title: "Wrong information", text: "Sorry, your login information is not in our system. Please check your username/email correctly.", confirmButtonText: "Okay"}).then(function() { window.location = "../login/index.php"; }); </script>'; } Quote Link to comment https://forums.phpfreaks.com/topic/314601-how-to-link-my-sweetalert-to-another-page-in-php-echo-tag/ Share on other sites More sharing options...
maxxd Posted March 15, 2022 Share Posted March 15, 2022 Use php to set a variable containing the number of rows in the HTML. Then use JavaScript to get that variable, check it, and react accordingly. Don't mix the two like you've done - technically, it's kinda possible but as you're seeing now it's a complete pain. Quote Link to comment https://forums.phpfreaks.com/topic/314601-how-to-link-my-sweetalert-to-another-page-in-php-echo-tag/#findComment-1594399 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.