0
我希望能夠從一行中讀取賬戶類型,並以$session
的名稱返回。假設我有一個名爲「accounts」的表格,其中有兩列用於用戶名和帳戶類型。當用戶登錄時,如果成功,它將啓動會話。這是當前的代碼:會話PHP的退貨行
if($count == 1 && $row['userPass']==$password && $row['type']=="Advanced") {
$_SESSION['userAdvanced'] = $row['userId'];
header("Location: index.php");
但是我想使它這樣我就可以有這樣的事情:
if($count == 1 && $row['userPass']==$password) {
$_SESSION['user'+[type]] = $row['userId'];
header("Location: index.php");
,這樣它會返回「userAdvanced」。
我還想在一個if語句中可以有多個$session
類型。我試過這個,但它不起作用:(而不是將兩個單獨的if語句合併成一個)。
<?php if(isset($_SESSION['userBasic'],['userAdvanced'])){ ?>
<a class="link" href="/index.php?logout" style="text-decoration:none">Logout</a>
道歉,如果這沒有多大意義,請讓我知道該怎麼做才能改善問題。謝謝。
Awesome stuff thanks @LeoAso – noone