2017-01-18 1 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

アカウントの種類Dean、Registrar、Incharge of Accounts、Cashier_を使用して、特定のページに接続しているかどうかを確認します。 – RiggsFolly

+0

ユーザーモデルにロールを設定していれば、その情報を使用することができます。特定のページにリダイレクトする。 –

+0

構文のerror – RiggsFolly

関連する問題