我已经创建了一个用户现在可以成功登录的网站,但是根据用户所在的组,我想在登录后将它们重定向到不同的页面。我有一个带有“training_group”行的数据库,例如,他们在组2013_1,他们将在登录后被引导到homepage_20131.php。
我一直在网上寻找教程,并找到了具有开关功能的可能解决方案?但我不确定如何/在哪里实现这一点。我刚开始学习 php,如果有任何建议,我将不胜感激!
现在,我的登录页面如下所示:
<?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) {
?>
<h2>We tried to log you in, but...</h2>
<?php
echo output_errors($errors);
}
include 'includes/overall/footer.php';
?>