2017-01-18 16 views
0

我一直在處理此PHP代碼,但我無法使用帳戶類型將它們連接到它們的特定頁面院長,註冊員,帳戶出納和收銀員根據用戶帳戶類型或使用用戶名和密碼重定向頁面

我的嘗試:

<?php include("header.php"); 
    include("banner.php") ?> 
    <?php 
     if (isset($_POST['btnlogin'])) { 
      $uname = trim($_POST['uname']); 
      $upass = trim($_POST['pass']); 

      $h_upass = sha1($upass); 
      if ($uname == '' OR $upass == '') { 
     } 
    ?> 
?> <script type="text/javascript"> 
     alert("Invalid Username and Password!"); 
    </script> 
<?php  
    } else { 
     $user = new User(); 
     $res = $user::AuthenticateUser($uname, $h_upass); 
?> 
+1

***您不應該使用[SHA1密碼哈希](https://konklone.com/post/why-google-is-hurrying-the-web-to-kill-sha-1) ***或*** [MD5密碼哈希](http://security.stackexchange.com/questions/19906/is-md5-considered-insecure)***,你真的應該使用PHP的[內置函數] (http://jayblanchard.net/proper_password_hashing_with_PHP.html)來處理密碼安全性。在散列之前,請確保你[不要越過密碼](http://stackoverflow.com/q/36628418/1011527)或使用其他任何清理機制。這樣做*更改密碼並導致不必要的附加編碼。 –

+1

另外你的代碼有語法錯誤。否則條件不與花括號關閉。 –

+1

也'IF'不會做任何事情,因爲這是'}' – RiggsFolly

回答

-1

您是否嘗試過用頭功能? 此外,如果您可以使用中間件將用戶重定向到特定文件,那將是很好的做法。

<?php include("header.php"); 
include("banner.php") ?> 
<?php 
if (isset($_POST['btnlogin'])) { 

    $uname = trim($_POST['uname']); 
    $upass = trim($_POST['pass']); 

    $h_upass = sha1($upass); 
    if ($uname == '' OR $upass == '') { 


} 
?> 
?> <script type="text/javascript"> 
       alert("Invalid Username and Password!"); 
       </script> 
      <?php 

    } else { 
     $user = new User(); 
     $res = $user::AuthenticateUser($uname, $h_upass); 
     if($res) 
     { 

      if($user->role == "Dean") 
      { 
      header('Location: Dean.php'); 
      }else if($user->role == "Dean") 
      { 
      header('Location: Registrar.php'); 
      } 

     } 

     } 

?> 
+0

這個答案_將他們連接到他們的具體頁面使用賬戶類型院長,註冊員,賬戶收費和出納_但我們不知道在那裏/如何存儲信息 – RiggsFolly

+0

我更新了我的答案,如果你的用戶模型有角色設置你可以使用它重定向到特定頁面。 –

+0

仍然需要在語法錯誤 – RiggsFolly

相關問題