I have database with 2 table. Students and Profesors. I create one more login table and there are all email and passwords from students and profesors. I want to create that Student try to login that will send him on some student.php and when profesor try to login it will send him on profesor.php
I try with this code, but it always return me 1. So this is not good options..
- if(isset($_POST['Submit'])){
-
- $sql= "SELECT COUNT (*) FROM `students` AND 'Profesors' WHERE `username` = :username and `password` = :password ";
- $result = $connection->prepare($sql);
- $result->bindParam(":username" ,$_POST['username']);
- $result->bindParam(":password" ,$_POST['password']);
- $result->execute();
-
- $num=$result->rowCount();
- if($num > 0){
- header("location:index.php");
- }else{
- header("location:login.php");
- }
I need some idea, how to change my datebase or this login code.