[英]How do I give specific users access to specific websites in PHP?
我正在構建一個登錄系統。 我的數據庫看起來像這樣<\/a>
比方說,登錄后,代碼會根據其 KURS 字段中的內容識別當前登錄的用戶並將其發送到特定網站。
所以用戶 yyy 將被發送到 TG111.php
用戶 uuu 將被發送到 TG112.php
TG111.php 看起來像這樣<\/strong>
<?php
session_start();
$sess = $_SESSION['KURS'];
if ($sess !== 'TG111') {
if ($sess !== 'TG112') {
if ($sess !== 'TG113') {
header("Location: index.php");
exit();
}
else {
header("Location: TG113.php");
exit();
}
}
else {
header("Location: TG112.php");
exit();
}
}
else {
header('Location: TG111.php');
exit();
}
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Hello</title>
</head>
<body>
<a href="logout.php">Abmelden</a>
</body>
</html>
我不確定你在找什么? 但是您可以嘗試調試它以查看問題所在,您可以嘗試在 if 語句中使用它
if($sess == 'TG111') {
header('Location: TG111.php');
exit();
} elseif ($sess == 'TG112') {
header("Location: TG112.php");
exit();
} elseif ($sess == 'TG113') {
header("Location: TG113.php");
exit();
} else {
header("Location: index.php");
exit();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.