I'm currently trying to redirect a current user type to it's specific site using sessions, whilst also creating a session to check if they are logged in.
The users are all in the same table and have been categorised with either 1, 2 or 3. This is what I have tried so far:
<?php
session_start();
include ('connection/conn.php');
$user = $_POST['userfield'];
$password = $_POST['passfield'];
$readcheck = "SELECT * FROM ovo_users WHERE id = '$user' AND pword = '$password' ";
$result = $conn->query($readcheck);
$numrow = $result->num_rows;
if($numrow > 0){
    while ($row = $result->fetch_assoc()){
        $userid = $row['id'];
        $usertype = $row['user_type'];
        $_SESSION['40212246_user_id'] = $userid;
        $_SESSION['40212246_user_type'] = $usertype;
    } 
    if($usertype = 1){
        header("Location: student/index.php");
    }
    elseif($usertype = 2){
        header("Location: tutor/index.php");
    }
    elseif($usertype = 3){
        header("Location: admin/index.php");
    }
    else {
        header("Location: index.php");
    }
}
?>
When I login I get sent to the student/index page no matter what login.
 
    