在重定向到php页面之前,警报未显示 [英] Before redirecting to a php page alert is not showing

查看:56
本文介绍了在重定向到php页面之前,警报未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示一个警告说错误的用户名和密码,然后必须重定向到同一页面(page1.php登录表单页面)。但它没有表现出来。只是它重定向。如果我采取标题功能na显示警报。所以帮我找到方法

I want to show one alert saying wrong username and password and then have to redirect to the same page(page1.php"login Form page"). But its not showing. simply it redirects.If i take header function na its showing alert. so help me to find a way

$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword"); 
header("location:page2.php");
}
else {
echo "<script type='text/javascript'>alert(\"Wrong Username or Password\")</script>";
header("location:page1.php");
}
?>

推荐答案

sql = SELECT * FROM
sql="SELECT * FROM


tbl_name WHERE username ='
tbl_name WHERE username='


myusername'和password ='
myusername' and password='


这篇关于在重定向到php页面之前,警报未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆