redirect based on user role stored in mysql database
<p>I've made a website that users can now successfully login to but depending on which group the user is in, I would like to redirect them to different pages after logging in. I have a database with a row "training_group" and if for example, they are in group 2013_1, they would be directed to homepage_20131.php after logging in. </p>

<p>I've been looking for tutorials online and have found a possible solution with a switch function? but I am unsure of how/where to implement this. I just started learning php and would be grateful for any advice given! </p>

<p>Right now, my login page looks like this: </p>

<pre><code>&lt;?php
include 'core/init.php'; 
if (empty($_POST) === false) {
    $username = $_POST['username'];
    $password = $_POST['password'];

    if (empty($username) === true || empty($password) === true) {
        $errors[] = 'please input a username and password first! ';
    } else if (user_exists($username) === false)    {
        $errors[] = 'We could not locate you in our database.';
    }    
    $login = login($username, $password);
    if ($login === false) {
        $errors [] = 'That username/password combination is incorrect';
    }    
    else {
        $_SESSION['user_id'] = $login;
        header('Location:logged_in/templates/logged_in_home.php');
        exit ();
    }
}
else {
    $errors [] = 'No data received';
}

include 'includes/overall/header.php';

if (empty ($errors) === false) {
    ?&gt;
    &lt;h2&gt;We tried to log you in, but...&lt;/h2&gt;
    &lt;?php
    echo output_errors($errors);
}
include 'includes/overall/footer.php'; 
?&gt;
</code></pre>
