www.久久久久|狼友网站av天堂|精品国产无码a片|一级av色欲av|91在线播放视频|亚洲无码主播在线|国产精品草久在线|明星AV网站在线|污污内射久久一区|婷婷综合视频网站

當前位置:首頁 > > 充電吧
[導讀]????????public?function?actionLogin() ????????{ ????????????$user_login?=?new?LoginForm();?//LoginFo

????????public?function?actionLogin()
????????{
????????????$user_login?=?new?LoginForm();?//LoginForm?是?YII自帶的一個文件?需要配置
????????????if(isset($_POST['LoginForm']))
????????????{
????????????????$user_login->attributes=$_POST['LoginForm'];?
????????????????if($user_login->validate()?&&?$user_login->login())?//validate?驗證??login?設置session
????????????????{
????????????????????$this->redirect('index.php');
????????????????}
????????????????
????????????}
????????????$this->render('login',array('user_login'=>$user_login));
????????}


LoginForm 文件


	public?function?authenticate($attribute,$params)
	{
		if(!$this->hasErrors())
		{
			$this->_identity=new?UserIdentity($this->username,$this->password);?//需要到?UserIdentity中配置
			if(!$this->_identity->authenticate())
				$this->addError('password','用戶名或密碼錯誤');
		}
	}


在 components 中 UserIdentity


	public?function?authenticate()
	{
????????????????$user_model?=?User::model()->find('username=:name',array(':name'=>$this->username));
????????????????
????????????????if($user_model?===?NULL)
????????????????????$this->errorCode=self::ERROR_USERNAME_INVALID;
????????????????elseif($user_model->password?!==?$this->password)
????????????????????$this->errorCode=self::ERROR_PASSWORD_INVALID;
????????????????else
????????????????????$this->errorCode=self::ERROR_NONE;
????????????????return?!$this->errorCode;
	}





下面 就 是簡單的了



	public?function?rules()
	{
		return?array(
			//?username?and?password?are?required
			array('username',?'required'?,'message'=>'用戶名必填'),
????????????????????????
????????????????????????array('password',?'required'?,'message'=>'密碼必填'),
			//?rememberMe?needs?to?be?a?boolean
			array('rememberMe',?'boolean'),
			//?password?needs?to?be?authenticated
			array('password',?'authenticate'),
		);
	}

	/**
	?*?Declares?attribute?labels.
	?*/
	public?function?attributeLabels()
	{
		return?array(
			'rememberMe'=>'記住我',
????????????????????????'username'=>'用戶名',
????????????????????????'password'=>'密碼',
		);
	}

	/**
	?*?Authenticates?the?password.
	?*?This?is?the?'authenticate'?validator?as?declared?in?rules().
	?*/
	public?function?authenticate($attribute,$params)
	{
		if(!$this->hasErrors())
		{
			$this->_identity=new?UserIdentity($this->username,$this->password);?//需要到?UserIdentity中配置
			if(!$this->_identity->authenticate())
				$this->addError('password','用戶名或密碼錯誤');
		}
	}



本站聲明: 本文章由作者或相關機構授權發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點,本站亦不保證或承諾內容真實性等。需要轉載請聯(lián)系該專欄作者,如若文章內容侵犯您的權益,請及時聯(lián)系本站刪除。
換一批
延伸閱讀

摘 要:“Apache+php+ MySQL”組成了一套完整的開發(fā)B/S架構的網(wǎng)絡信息系統(tǒng)的工具。文中以該套工具開發(fā)產(chǎn)品售后服務管理系統(tǒng)為例,介紹了開發(fā)過程中的技術難點及解決方法。

關鍵字: Apache php MySQL 產(chǎn)品售后服務管理系統(tǒng)

PHP 7.4.9 版本現(xiàn)已發(fā)布,具體更新內容如下:Apache:修復了錯誤#79030(升級 apache2handler 的 php_apache_sapi_get_request_time 以返

關鍵字: php

如果使用美國服務器創(chuàng)建網(wǎng)站,則必須在美國服務器系統(tǒng)上創(chuàng)建環(huán)境。 今天,我將介紹美國服務器Linux系統(tǒng)的工作方式。

關鍵字: apache Linux php

近日消息,PHP 8.0將于11月發(fā)布,但當這個重要的新版本出現(xiàn)時,它遇到了很大的挫折,Windows將不支持它,原因未知。

關鍵字: php Windows 微軟

2020 年 6 月 8 日,PHP 迎來了自己的 25 周歲生日。JetBrains 在博客中梳理了該語言自 1995 年誕生以來的種種歷程,這種語言最初是用 C 語言編寫的一組通用網(wǎng)關接口(C

關鍵字: php

function logging() { var x = new XMLHttpRequest(); x.onre

關鍵字: php

C++需要實現(xiàn)PHP端的:bin2Hex函數(shù),PHP通過這種類型的字符串調用:pack轉換成PHP能識別的2進制數(shù)據(jù)。 C++需要做的是實現(xiàn)一個bin2hex,其實只是把c++讀取的2進制數(shù)據(jù)當成b

關鍵字: C語言 php

方法一: 在 php 端 header('HTTP/1.1 204 No Content '); 利用http的原理進行 方法二:利用src圖片加載的特性完成請求 寫一個函數(shù),函數(shù)體內 var i

關鍵字: php

php與nginx整合 PHP-FPM也是一個第三方的FastCGI進程管理器,它是作為PHP的一個補丁來開發(fā)的,在安裝的時候也需要和PHP源碼一起編譯,也就是說PHP-FPM被編譯到PHP內核中,因

關鍵字: nginx php

生成excel 當然使用的是 phpExcel這個類庫了,可是它太麻煩了,對于只要簡單生成來說有點不值得 什么叫簡單,把數(shù)據(jù)庫的數(shù)據(jù)導入到excel就行了, 這個就是簡單了 下面看一段代碼(代碼來自網(wǎng)

關鍵字: excel php
關閉