[英]Php redirect to another page
I tried using different techniques and saw other people using this method. 我尝试使用不同的技术,并看到其他人使用此方法。 I dont understand why mine isn't working. 我不明白为什么我的不工作。 It only redirects to the first "if" conditon 它仅重定向到第一个“ if”条件
$username = $_POST['user'];
$password = $_POST['pass'];
$sql2= "SELECT * FROM `user` WHERE username='$username' AND password='$password' ";
$sql3="SELECT usertype from `user` WHERE username='$username'";
//$result = $con->query($sql2);
$result=mysqli_query($conmfadb,$sql2);
// Mysql_num_row is counting table row
$count=mysqli_num_rows($result);
#echo $count;
//Query to redirect
$pageSelect=mysqli_query($conmfadb,$sql3);
// If result matched $mail and $pwd, table row must be 1 row
if($pageSelect="admin"){
echo"
<script type='text/javascript'>location.href = 'menu.php';</script>";
} elseif($pageSelect="user"){
if ($count >= 1) {
echo"
<script type='text/javascript'>location.href = 'form/form.php';</script>";
} else {
echo "Your attempt is Unsuccessful! $count";
}
}
else
{
echo"error";
}`
try this below . 在下面试试这个。 It's working 工作正常
if($pageSelect="admin")
{
?>
<script type='text/javascript'>location.href = 'menu.php';</script>";
<?php
}
elseif($pageSelect="user")
{
if ($count >= 1) {
?>
<script type='text/javascript'>location.href = 'form/form.php';</script>";
<?php
}
else {
echo "Your attempt is Unsuccessful! $count";
}
}
else
{
echo"error";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.