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
$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";
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.