Advertisement
Guest User

Untitled

a guest
Jan 29th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.36 KB | None | 0 0
  1. // login_agent.php
  2. <?php
  3. include_once '../../include/config.php';
  4. include_once ROOT_PATH .'/include/startup.php';
  5.  
  6. $iErrorLogin = 0;
  7. if ( isset($_POST['username']) ) {
  8.     $strUsername = trim($_POST['username']);
  9.  
  10.     $strPassword = trim($_POST['password']);
  11.  
  12.     include_once ROOT_PATH ."/class/clsAgent.php";
  13.     $clsAgent   = new clsAgent();
  14.     $infoAgentUser  = $clsAgent->getDataByUsername($strUsername);
  15.  
  16.     if ( isset($infoAgentUser['id']) && $infoAgentUser['id'] > 0 ) {
  17.         if ( $infoAgentUser['password'] == md5($strPassword) ) {
  18.             if ($infoAgentUser['status'] > 0) {
  19.  
  20.                 include_once ROOT_PATH ."/class/clsAgentMenu.php";
  21.                 $clsAgentMenu = new clsAgentMenu();
  22.                 $infoAgentUser['MENU'] = $clsAgentMenu->getLst();
  23.  
  24.                 $_SESSION['agent_info'] = $infoAgentUser;
  25.                 header('Location: '. ROOT_URL.'/agent/info');
  26.  
  27.             } else {
  28.                 $iErrorLogin = 3;
  29.             }
  30.         } else {
  31.             $iErrorLogin = 2;
  32.         }
  33.     } else {
  34.         $iErrorLogin = 1;
  35.     }
  36. }
  37.  
  38. $objSmarty->assign('iErrorLogin',           $iErrorLogin);
  39. $objSmarty->display('admin_agent/login.tpl');
  40. ?>
  41.  
  42. class clsAgent {
  43.     function getDataByUsername($strUsername){
  44.         if($strUsername != ''){
  45.             $arrResult = array();
  46.             $sql = "select * from " . $this->_tableName . " where lower(username) = lower('" . $strUsername. "')";
  47.             $clsDB = new clsDB();
  48.             $arrResult = $clsDB->fetchRowSQL($sql);
  49.             return $arrResult;
  50.         }
  51.     }
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement