PHP警报消息

编程入门 行业动态 更新时间:2024-10-11 03:18:38
本文介绍了PHP警报消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我知道每个人都要说的第一件事是,这已经发布了几百次;然而,我已经尝试了所有不同的方法,人们建议仍然没有运气...我试图得到一个警告消息弹出如果登录失败,但由于某种原因,该消息不想出现。这是我到目前为止:

I know the first thing everyone is going to say is that this has been posted hundreds of times; however, I have tried all the different methods people have suggested with still no luck... I am trying to get an alert message to popup if the login fails but for some reason the message does not want to appear. Here's what I have so far:

if($conn) { $result=sqlsrv_query($conn, "SELECT * FROM Operator WHERE Username='{$_POST['login']}'"); $pass=sqlsrv_fetch_array($result); if($pass["Password"] === $_POST['password']) { session_start(); $_SESSION['loggedin']=true; header("Location: home.php"); exit; } else { header("Location: login.php"); echo '<script type="text/javascript">'; echo 'alert("Password Invalid!")'; echo '</script>'; } } sqlsrv_close($conn);

php工作正常,但由于某种原因,我无法使javascript工作。任何想法?

The php is working fine but for some reason I can't get the javascript to work. Any ideas?

推荐答案

我想,问题在这里。

header("Location: login.php"); /* Redirect browser */

尝试删除它,或在几秒钟后重定向

try removing it, or make it redirect after a couple of seconds, like this

header( "refresh:5;url=login.php" ); //redirect after 5 seconds

或者提示用户单击进入下一页的对话框。移除标头()tho

or you prompt a dialog for the user to click to go to next page. remove the header() tho

<script type="text/javascript"> <!-- var retVal = confirm("Login FAILED! Do you want to continue ?"); if( retVal == true ){ window.location.href = "login.php"; return true; }else{ alert("User does not want to continue!"); return false; } //--> </script>

更多推荐

PHP警报消息

本文发布于:2023-11-27 17:54:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639015.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   消息   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!