Redirect Users to different pages based on user role php RRS feed

  • Question

  • I need to redirect users to two (2) different pages based on the roles given to them in the database. Only the email and password is submitted on the login page. I have to fetch the role from the database which looks like this:

      Email   |  Password  |   UserType    xxxxxx       System User    xxxxxx       Administrator

    And here is what I have done so far:



        $query=mysqli_query($con,"select ID from gts_users where  Email='$email' && Password='$password' ");


         case 'System User':
         header('location: dashboard.php');
         case 'Administrator':
         header('location: admin/index.html');
    echo "<script type='text/javascript'>alert('Wrong email and password combination');


    <form action="" method="post">

    <input type="email" placeholder="E-mail" name="email">

    <input type="password" name="password" placeholder=" Password">

    <button type="submit" value="login" name="login">Login</button>


    • Edited by Speed Ack Thursday, July 18, 2019 7:17 PM Incomplete
    Thursday, July 18, 2019 7:13 PM