如何将我的 sweetalert 链接到 php echo 标签中的另一个页面?
我正在使用 Sweet Alert 向用户发送一条警告消息,向他们显示信息插入在 PHP echo 中无效。我想要“好的”按钮链接到所需页面,但它无法工作。我的开发人员控制台显示 login.php:29 Uncaught TypeError: Cannot read properties of undefined (reading 'then')
错误,但我不知道如何才能完成这项工作。我花了几个小时四处寻找,但就是没有。任何向我伸出援助之手的人都会受到真正的感激。谢谢。
以下是我的代码:
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>';
}
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>';
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论