日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

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

????????public?function?actionLogin()
????????{
????????????$user_login?=?new?LoginForm();?//LoginForm?是?YII自帶的一個(gè)文件?需要配置
????????????if(isset($_POST['LoginForm']))
????????????{
????????????????$user_login->attributes=$_POST['LoginForm'];?
????????????????if($user_login->validate()?&&?$user_login->login())?//validate?驗(yàn)證??login?設(shè)置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','用戶名或密碼錯(cuò)誤');
		}
	}


在 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;
	}





下面 就 是簡(jiǎn)單的了



	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','用戶名或密碼錯(cuò)誤');
		}
	}



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

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

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

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

關(guān)鍵字: php

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

關(guān)鍵字: apache Linux php

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

關(guān)鍵字: php Windows 微軟

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

關(guān)鍵字: php

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

關(guān)鍵字: php

C++需要實(shí)現(xiàn)PHP端的:bin2Hex函數(shù),PHP通過(guò)這種類(lèi)型的字符串調(diào)用:pack轉(zhuǎn)換成PHP能識(shí)別的2進(jìn)制數(shù)據(jù)。 C++需要做的是實(shí)現(xiàn)一個(gè)bin2hex,其實(shí)只是把c++讀取的2進(jìn)制數(shù)據(jù)當(dāng)成b

關(guān)鍵字: C語(yǔ)言 php

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

關(guān)鍵字: php

php與nginx整合 PHP-FPM也是一個(gè)第三方的FastCGI進(jìn)程管理器,它是作為PHP的一個(gè)補(bǔ)丁來(lái)開(kāi)發(fā)的,在安裝的時(shí)候也需要和PHP源碼一起編譯,也就是說(shuō)PHP-FPM被編譯到PHP內(nèi)核中,因

關(guān)鍵字: nginx php

生成excel 當(dāng)然使用的是 phpExcel這個(gè)類(lèi)庫(kù)了,可是它太麻煩了,對(duì)于只要簡(jiǎn)單生成來(lái)說(shuō)有點(diǎn)不值得 什么叫簡(jiǎn)單,把數(shù)據(jù)庫(kù)的數(shù)據(jù)導(dǎo)入到excel就行了, 這個(gè)就是簡(jiǎn)單了 下面看一段代碼(代碼來(lái)自網(wǎng)

關(guān)鍵字: excel php
關(guān)閉