In my program, I want different users to have different class_id in order to let them go into different mange page. I distribute them in 3 class id 1= manger 2= NormalUser 3 =admin but when I full outer join them I think the error is here. but i can’t find it can someone help?
the problem is in query
<?php session_start();?> <?php include("conn.php"); ?> <?php if(isset($_POST['submit'])) { $user=$_POST['username']; $pwd=$_POST['password']; $query="SELECT * FROM employees FULL OUTER JOIN admin on employees.class_id=admin.class_id WHERE (employees.employee_id='$user'&& employees.password='$pwd') ||(admin.username='$user' && admin.password='$pwd')"; $data = mysqli_query($conn,$query); $total =mysqli_num_rows($data); $class = $data->fetch_assoc(); if ($class['class_id']==2) { $_SESSION['employee_id']=$user; header('location:home.php'); } elseif ($class['class_id']==1){ $_SESSION['employee_id']=$user; header('location:manger/home.php'); } else { header('location:index.php'); } } ?>
Advertisement
Answer
the problem is here :
use ‘AND’,’OR’ instead of &&,||
WHERE (employees.employee_id='$user' AND employees.password='$pwd') OR (admin.username='$user' AND admin.password='$pwd')"