This a multi login system, so when a user logs in, they can only see what is meant for them to see, only the admin can see all of the user's info.
This works at home, but when I take it to the server it won't work because of outdated PHP libraries. I know at some point that would have to be updated but it is out of my hands. I hope someone can help me out with this.
I can't use mysqli_stmt::get_result (because of outdated PHP). Can anybody help me adequate this code with mysqli_stmt::bind_result and mysqli_stmt::fetch?
To update libraries in PHP is not an option at this point.
<?php
    session_start();
    $conn = new mysqli("localhost","root","root","numbers");
    $msg="";
    if(isset($_POST['login'])){
        $username = $_POST['username'];
        $password = $_POST['password'];
        $password = sha1($password);
        $userType = $_POST['userType'];
        $sql = "SELECT * FROM users WHERE username=? AND password=? AND user_type=?";
        $stmt=$conn->prepare($sql);
        $stmt->bind_param("sss",$username,$password,$userType);
        $stmt->execute();
        $result = $stmt->get_result();
        $row = $result->fetch_assoc();
        session_regenerate_id();
        $_SESSION['username'] = $row['username'];
        $_SESSION['role'] = $row['user_type'];
        session_write_close();
        if($result->num_rows==1 && $_SESSION['role']=="user1"){
            header("location:user1.php");
        }
        else if($result->num_rows==1 && $_SESSION['role']=="user2"){
            header("location:user2.php");
        }
        else if($result->num_rows==1 && $_SESSION['role']=="user3"){
            header("location:user3.php");
        }
        else if($result->num_rows==1 && $_SESSION['role']=="admin"){
            header("location:admin.php");
        }
        else {
            $msg = "Username and/or password incorrect!";
        }
    }
?>
 
    