當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserModel::getUserByUsername方法代碼示例

本文整理匯總了PHP中UserModel::getUserByUsername方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserModel::getUserByUsername方法的具體用法?PHP UserModel::getUserByUsername怎麽用?PHP UserModel::getUserByUsername使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UserModel的用法示例。


在下文中一共展示了UserModel::getUserByUsername方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: registerAction

 /**
  * 注冊
  */
 public function registerAction()
 {
     $username = trim($this->getRequest()->getPost('username', ''));
     $password = trim($this->getRequest()->getPost('password', ''));
     $email = trim($this->getRequest()->getPost('email', ''));
     //校驗參數是否為空
     if (empty($username) || empty($password) || empty($email)) {
         $this->getView->assign('message', '參數不能為空');
         $this->getView->render('/user/index.phtml');
     }
     $userModel = new UserModel();
     //校驗用戶名是否存在
     $isExistUsername = $userModel->getUserByUsername($username);
     if ($isExistUsername) {
         $this->getView->assign('message', '用戶名已存在');
         $this->getView->render('/user/index.phtml');
     }
     //校驗郵箱是否存在
     $isExistEmail = $userModel->getUserByEmail($email);
     if ($isExistEmail) {
         $this->getView()->assign('message', '郵箱已存在');
         $this->getView()->render('/user/index.phtml');
     }
     //進行注冊
     $flag = $userModel->addUser($username, $password, $email);
     //如果成功,登錄返回首頁
     if ($flag) {
         Yaf_Session::getInstance()->set('userId', $flag);
         $this->getView()->render('/index/index.phtml');
     } else {
         $this->getView()->assign('message', '注冊失敗');
         $this->getView()->render('/user/index.phtml');
     }
 }
開發者ID:ancongcong,項目名稱:todo_project,代碼行數:37,代碼來源:User.php

示例2: getUserTable

 function getUserTable($username)
 {
     $userModel = new UserModel();
     $user = $userModel->getUserByUsername($username);
     $result = "";
     if ($user) {
         $result = "<div class = 'small-8 column userAccount'>\n\t\t\t\t\t\t<form action='' method='post'>\n\t\t\t\t\t\t\t<label>First name: \n\t\t\t\t\t\t\t\t<input type='text' name = 'firstname' value='{$user->firstname}' />\n\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t<label>Last name: \n\t\t\t\t\t\t\t\t<input type='text' name = 'lastname' value='{$user->lastname}' />\n\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t<label>Email: \n\t\t\t\t\t\t\t\t<input type='text' name = 'email' value='{$user->email}' />\n\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t<label>Username: \n\t\t\t\t\t\t\t\t<input type='text' name = 'username' value='{$user->username}' />\n\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t<input name='modify' type='submit' value=' Modify ' id='mod'>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t</form>\t\n\t\t\t\t\t   </div>";
     }
     return $result;
 }
開發者ID:ralucabolba,項目名稱:E-Biblio,代碼行數:10,代碼來源:user_controller.php

示例3: sigin

 /**
  * 後台登錄驗證
  */
 public function sigin()
 {
     //接收用戶提交數據
     $username = trim($_REQUEST['username']);
     $password = trim($_REQUEST['password']);
     //驗證碼
     $captcha = trim($_REQUEST['captcha']);
     if (empty($captcha)) {
         // 跳轉登錄頁麵
         $this->error('index.php', '驗證碼不能為空!');
     }
     //驗證數據
     if (empty($username) or empty($password)) {
         // 跳轉登錄頁麵
         $this->error('index.php', '用戶名或密碼不能為空!');
     }
     // 驗證碼比對
     Captcha::IsCaptcha($captcha);
     if (!$captcha) {
         // 跳轉登錄頁麵
         $this->error('index.php', '驗證碼錯誤!');
     }
     //合理性驗證
     $admin = new UserModel();
     //查詢表中是否存在當前用戶數據
     $user = $admin->getUserByUsername($username);
     //判斷用戶是否存在
     if (!$user) {
         $this->error('index.php', '當前用戶名不存在!');
     }
     //對比密碼 拚接密碼進行md5驗證
     if ($user['u_password'] == md5('sh_' . $password)) {
         $_SESSION['adminuser'] = $user;
         // 更新IP地址及登錄時間
         $admin->setUpdateLoginInfo($user['u_id']);
         // 添加登錄日誌
         $logs = new LogsModel();
         $logs->insertOne($user['u_name'] . "用戶登錄");
         //判斷用戶是否選擇了記住用戶信息
         // if (isset($_POST['remember'])) {
         //     //設置cookies
         //     setcookie('U_id',$user['id'],time()+7*24*3600);
         // }
         //登錄成功
         $this->success('index.php?c=Index&a=index', '驗證成功!', 1);
     } else {
         $this->error('index.php', '用戶密碼錯誤!!');
     }
 }
開發者ID:0x584A,項目名稱:PHP_Simple_MVC,代碼行數:52,代碼來源:PrivilegeController.class.php

示例4: loginAction

 /**
  * Login
  *
  * @return string
  */
 public function loginAction()
 {
     $success = false;
     $error = '';
     require_once ZOODPP_APP . '/models/UserModel.php';
     $username = $this->getParam('username');
     $password = $this->getParam('password');
     $persistent = $this->getParam('persistent');
     $persistent = $persistent ? 1 : 0;
     $user = UserModel::getUserByUsername($username);
     if (empty($user)) {
         $error = 'User is not existent';
     } else {
         if ($user['password'] != $password) {
             $error = 'Incorrect password';
         } else {
             $success = true;
         }
     }
     if ($success) {
         require_once ZOODPP_APP . '/models/SessionModel.php';
         $sessionid = session_id();
         $csession = SessionModel::getSessionBySessionid($sessionid);
         $session = array('sessionid' => $sessionid, 'userid' => $user['userid'], 'username' => $user['username'], 'persistent' => $persistent, 'ip' => Zood_Util::clientIP(), 'user_agent' => $_SERVER['HTTP_USER_AGENT']);
         if ($csession) {
             SessionModel::updateSession($session, $sessionid);
         } else {
             SessionModel::addSession($session);
         }
         if ($persistent) {
             setcookie('ZOODSID', $sessionid, time() + 36000 * 24 * 30, '/');
         } else {
             setcookie('ZOODSID', $sessionid, null, '/');
         }
         $_SESSION['ZOODSID'] = $sessionid;
         $u = $this->getU();
         header('Location: ' . $u);
         exit;
     } else {
         $this->addResult(self::RESULT_SUCCESS, 'php', 'login/index.php');
         $this->setData($this->getUserParams());
         $this->setData('error', $error);
         $this->setData('u', $this->getU());
         return self::RESULT_SUCCESS;
     }
 }
開發者ID:BGCX261,項目名稱:zoodphp-svn-to-git,代碼行數:51,代碼來源:IndexController.php

示例5: UserModel

<?php

include_once "models/user_model.php";
$userModel = new UserModel();
if (session_status() == PHP_SESSION_NONE) {
    session_start();
}
$reverror = '';
if (isset($_POST['addreview'])) {
    if (empty($_POST['comment'])) {
        $reverror = "You must write your review";
    } else {
        $description = $_POST['comment'];
        //echo $_SESSION['login_user'];
        $user = $userModel->getUserByUsername($_SESSION['login_user']);
        $idUser = $user->idUser;
        $idBook = $_SESSION['current_book'];
        // To protect MySQL injection for Security purpose
        $description = stripslashes($description);
        $description = mysql_real_escape_string($description);
        $idUser = stripslashes($idUser);
        $idUser = mysql_real_escape_string($idUser);
        $idBook = stripslashes($idBook);
        $idBook = mysql_real_escape_string($idBook);
        require "testdb.php";
        $query = "INSERT INTO review(description, approved, idUser, idBook) VALUES ('{$description}', 0, {$idUser}, {$idBook})";
        //echo $query;
        $result = mysql_query($query) or die(mysql_error());
        if ($result) {
            echo "Your review was saved";
        } else {
開發者ID:ralucabolba,項目名稱:E-Biblio,代碼行數:31,代碼來源:addreview.php

示例6: actionGetUserTeams

 /**
  * @desc 獲取球員所加入的球隊
  */
 public function actionGetUserTeams()
 {
     if (!Yii::app()->request->isAjaxRequest) {
         throw new CHttpException(500, '此方法隻允許ajax調用');
     }
     $masterId = CommonFunction::getUserId();
     $leagueModel = new LeagueModel();
     $res = $leagueModel->findByMaster($masterId, 1);
     if (empty($res)) {
         throw new CHttpException(500, '該用戶無權限管理聯賽');
     }
     $username = Yii::app()->request->getQuery('username');
     $user = new UserModel();
     $userRes = $user->getUserByUsername($username);
     if (empty($userRes)) {
         CommonFunction::ajaxResult(State::$SUSSION_CODE, State::$SUSSION_MSG, "noteam");
     } else {
         $userid = $userRes[0]->objectId;
     }
     //		var_dump($userRes);
     //		echo $userid;
     $teamModel = new TeamModel();
     $userTeams = $teamModel->findTeamsByCaptain($userid);
     $userTeamNameArr = array();
     foreach ($userTeams as $userTeam) {
         if (isset($userTeam->name)) {
             array_push($userTeamNameArr, $userTeam->name);
         }
     }
     CommonFunction::ajaxResult(State::$SUSSION_CODE, State::$SUSSION_MSG, array('response' => json_encode($userTeamNameArr)));
 }
開發者ID:JimmyFung,項目名稱:BmobTiQiuBa,代碼行數:34,代碼來源:ManageController.php


注:本文中的UserModel::getUserByUsername方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。