我创建了一个用户需要登录的网页。我想让用户看到他/她的信息。那是说你好user1并单击此处注销。这是我的代码,我什至看不到注销按钮。
更新:我看到我没有使用该用户名登录的用户名。我用用户名学生进入了网站。但它显示不同的用户名。见下图。它应该写 welcome student 而不是 yasemin
登录代码:
// LOGIN USER
if (isset($_POST['login_user'])) {
$username = mysqli_real_escape_string($db, $_POST['username']);
$password = mysqli_real_escape_string($db, $_POST['password']);
if (empty($username)) {
array_push($errors, "Username is required");
}
if (empty($password)) {
array_push($errors, "Password is required");
}
if (count($errors) == 0) {
$password = md5($password);
$query = "SELECT * FROM users WHERE username='$username' AND password='$password'";
$results = mysqli_query($db, $query);
$row = mysqli_fetch_assoc($results);
if('student' == $row['user_type']) {
header('Location: ogrenciarayuzu.php');
exit();
} elseif ('department' == $row['user_type']) {
header('Location: bolumsekreterligiarayuzu.php');
exit();
} elseif ('institute' == $row['user_type']) {
header('Location: enstituarayuzu.php');
exit();
}
if (mysqli_num_rows($results) == 1) {
$_SESSION['username'] = $username;
$_SESSION['success'] = "You are now logged in";
header('location: index.php');
}else {
array_push($errors, "Wrong username/password combination");
}
}
}
?>
Cats萌萌