2016-07-31 31 views
0

如何允許用戶和管理員通過同一頁面登錄,但使用超薄PHP和MySQL數據庫,例如重定向到不同的頁面允許用戶和管理員通過一個單一頁面登錄使用超薄PHP

if(sid = 0) { 
    //redirect to admin dashboard} 
else if (sid = 1) { 
    //redirect to user dashboard} 
+0

非常像你的例子。從數據庫獲取用戶數據以驗證憑據時,請檢查它是管理員還是用戶。 – Philipp

回答

0

您可以使用header函數來執行重定向,並假設您有一個名爲admin的數據庫列,對於是,則爲1,否則爲0,否則您可以執行以下操作。

if($row['admin'] == 1) // if admin, load this url - otherwise load second url 
{ 
    header('Location: http://www.google.com/'); 
} 
else 
{ 
    header('Location: http://www.stackoverflow.com/'); 
} 
相關問題