<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DFdou&#039;s Blog &#187; Login</title>
	<atom:link href="http://nwhy.org/tag/login/feed" rel="self" type="application/rss+xml" />
	<link>http://nwhy.org</link>
	<description>Life is short,Be yourself.</description>
	<lastBuildDate>Wed, 08 Sep 2010 05:34:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>AIR-远程登录验证Login Check</title>
		<link>http://nwhy.org/air-login-application.html</link>
		<comments>http://nwhy.org/air-login-application.html#comments</comments>
		<pubDate>Mon, 04 May 2009 09:34:19 +0000</pubDate>
		<dc:creator>DFdou</dc:creator>
				<category><![CDATA[AIR+FB+AS3]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Discuz]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Login]]></category>

		<guid isPermaLink="false">http://nwhy.org/?p=4247</guid>
		<description><![CDATA[今天测试了下AIR的远程登录，其实代码和一般的程序是没有区别的，就是发布成了AIR，所以可以远程登录。 With Flash CS4 we can create AIR application now,this is a simple AIR application to login with AIR APP. AS Code... ]]></description>
			<content:encoded><![CDATA[<p>今天测试了下AIR的远程登录，其实代码和一般的程序是没有区别的，就是发布成了AIR，所以可以远程登录。<br />
With Flash CS4 we can create AIR application now,this is a simple AIR application to login with AIR APP.<br />
AS Code:<br />
[js]<br />
package {<br />
	import flash.display.MovieClip;<br />
	import flash.events.MouseEvent;<br />
	import flash.events.Event;<br />
	import flash.net.*;<br />
	import com.adobe.utils.StringUtil;</p>
<p>	public class Login extends MovieClip {<br />
		public function Login():void {<br />
			initLogin();<br />
		}<br />
		public function initLogin():void {<br />
			txtPwd.displayAsPassword=true;<br />
			btn_login.addEventListener(MouseEvent.CLICK,loginAPP);<br />
		}<br />
		internal function loginAPP(_evt:MouseEvent) {<br />
			txtResult.text="登录中...";<br />
			var uname=StringUtil.trim(txtName.text);<br />
			var upwd=StringUtil.trim(txtPwd.text);<br />
			if(checkInput(uname) &#038;& checkInput(upwd)){<br />
				var loader:URLLoader=new URLLoader();<br />
				var loginURL:URLRequest=new URLRequest("login.php");//login check url<br />
				var loginVar:URLVariables=new URLVariables();<br />
				loginVar.uname=uname;<br />
				loginVar.upwd=upwd;<br />
				loginURL.data=loginVar;<br />
				loginURL.method=URLRequestMethod.POST;<br />
				loader.addEventListener(Event.COMPLETE,loginComplete);<br />
				try {<br />
					loader.load(loginURL);<br />
				} catch (error:ArgumentError) {<br />
					trace("参数错误");<br />
				} catch (error:SecurityError) {<br />
					trace("发生安全错误");<br />
				}<br />
			}else{<br />
				txtResult.text="信息输入不完整！";<br />
			}<br />
		}<br />
		internal function checkInput(strInput:String):Boolean{<br />
			if(strInput==""){<br />
				return false;<br />
			}else{<br />
				return true;<br />
			}<br />
		}<br />
		internal function loginComplete(_evt:Event) {<br />
			var rsResult:String=_evt.target.data;<br />
			switch(rsResult){<br />
				case "1000":<br />
					txtResult.text="登录成功";<br />
					break;<br />
				case "1001":<br />
					txtResult.text="密码错误！";<br />
					break;<br />
				case "1002":<br />
					txtResult.text="用户名不存在！";<br />
					break;<br />
			}<br />
		}<br />
	}<br />
}<br />
[/js]<br />
<span id="more-4247"></span><br />
PHP部分的代码，用了Discuz来做测试，这部分的大家看着自己写吧～<br />
[php]<br />
< ?php<br />
require_once("../include/common.inc.php");//Use discuz bbs's common.inc.php<br />
$uname=$_POST["uname"];<br />
$sql="SELECT salt FROM uc_members WHERE username='$uname' LIMIT 1";<br />
$rs = $db->query($sql);<br />
$rscount=@mysql_num_rows($rs);<br />
if($rscount>0){<br />
	$rows=$db->fetch_array($rs);<br />
	$salt=$rows["salt"];<br />
	$upwd=md5(md5($_POST["upwd"]).$salt);//discuz user password<br />
	$sql="SELECT uid,username FROM {$tablepre}members WHERE username='$uname' AND password='$upwd'";<br />
	$rs = $db->query($sql);<br />
	$result=@mysql_num_rows($rs);<br />
	if($result==0){<br />
		echo "1001";//pwd failed<br />
	}else{<br />
		echo "1000";//login success<br />
	}<br />
}else{<br />
	echo "1002";//no user name<br />
}<br />
?><br />
[/php]</p>
<h4  class="related_post_title">Some Related Posts</h4><ul class="related_post"><li>2009/05/14 -- <a  href="http://nwhy.org/aas3wdp-virtual-proxy.html" title="AAS3WDP-Chapter 6 Virtual Proxy 虚拟代理模式">AAS3WDP-Chapter 6 Virtual Proxy 虚拟代理模式</a> (0)</li><li>2009/11/27 -- <a  href="http://nwhy.org/flash-new-knowledge-exchange-for-flexflashair-developers.html" title="Flash-New knowledge exchange for Flex/Flash/AIR developers">Flash-New knowledge exchange for Flex/Flash/AIR developers</a> (1)</li><li>2009/11/04 -- <a  href="http://nwhy.org/flash-global-error-handling-in-air-2-0-and-flash-10-1.html" title="Flash-Global Error Handling in AIR 2.0 and Flash 10.1">Flash-Global Error Handling in AIR 2.0 and Flash 10.1</a> (0)</li><li>2009/09/07 -- <a  href="http://nwhy.org/as3-physics-formula.html" title="Flash-一些常用物理公式和AS3的结合应用">Flash-一些常用物理公式和AS3的结合应用</a> (1)</li><li>2009/07/28 -- <a  href="http://nwhy.org/flash-fuzzy-theory.html" title="Flash &#8211; 说是XXX的模糊理论视觉模型？">Flash &#8211; 说是XXX的模糊理论视觉模型？</a> (2)</li><li>2009/07/27 -- <a  href="http://nwhy.org/flash-setter-getter.html" title="Flash-Setter &#038; Getter">Flash-Setter &#038; Getter</a> (0)</li><li>2009/07/20 -- <a  href="http://nwhy.org/game-avoid-bullets-2.html" title="AS3-子弹躲避游戏(下)">AS3-子弹躲避游戏(下)</a> (0)</li><li>2009/07/17 -- <a  href="http://nwhy.org/game-avoid-bullets-1.html" title="AS3-子弹躲避游戏(上)">AS3-子弹躲避游戏(上)</a> (1)</li><li>2009/07/13 -- <a  href="http://nwhy.org/as3-code-optimization.html" title="AS3 Code Optimization一些代码优化的问题">AS3 Code Optimization一些代码优化的问题</a> (0)</li><li>2009/06/25 -- <a  href="http://nwhy.org/flash-megazine3.html" title="Flash-An Pageflip/Flashbook Engine MegaZine 3">Flash-An Pageflip/Flashbook Engine MegaZine 3</a> (4)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://nwhy.org/air-login-application.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP-登录，Cookie，登出</title>
		<link>http://nwhy.org/php-sign-cookie-logout.html</link>
		<comments>http://nwhy.org/php-sign-cookie-logout.html#comments</comments>
		<pubDate>Fri, 27 Mar 2009 06:45:03 +0000</pubDate>
		<dc:creator>DFdou</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Cookie]]></category>
		<category><![CDATA[Login]]></category>
		<category><![CDATA[Logout]]></category>

		<guid isPermaLink="false">http://nwhy.org/?p=4061</guid>
		<description><![CDATA[登录页，login.php： [php] < ?php require "conn.php"; header("Content-Type: text/html; charset=utf-8"); ob_start();//打开缓冲区 $cookietime=time()+3600;//设置Cookie有效时间 $uname=$_POST['uname'];//接收传过来的用户名 $upwd=md5($_P... ]]></description>
			<content:encoded><![CDATA[<p>登录页，login.php：<br />
[php]<br />
< ?php require "conn.php";<br />
header("Content-Type: text/html; charset=utf-8");<br />
ob_start();//打开缓冲区<br />
$cookietime=time()+3600;//设置Cookie有效时间<br />
$uname=$_POST['uname'];//接收传过来的用户名<br />
$upwd=md5($_POST['upwd']);//接收传过来的密码并md5()<br />
$sql="SELECT * FROM admin WHERE u_name='$uname' AND u_pwd='$upwd'";//查询数据库<br />
$rs=mysql_query($sql);<br />
$num=@mysql_num_rows($rs);//获取查询结果的条数<br />
if(!($num>0))//0就是木有匹配的记录<br />
{<br />
echo "<script>alert('用户名或密码错误，请重新输入。');location.href='index.php'</script>";//重新登录去～<br />
}else{<br />
setcookie('uname',$uname,$cookietime);//设置Cookie<br />
setcookie('upwd',$upwd,$cookietime);<br />
echo "<script>location.href='xxx.php'</script>";//跳转<br />
}<br />
?><br />
[/php]<br />
<span id="more-4061"></span><br />
Cookie.php，用于判断用户当前是否已登录：<br />
[php]<br />
< ?php<br />
ob_start();<br />
$uname=$_COOKIE["uname"];//获取Cookie值<br />
$upwd=$_COOKIE["upwd"];<br />
$sql="SELECT * FROM admin WHERE u_name='$uname' AND u_pwd='$upwd'";//查询Cookie中保存的用户名密码是否在数据库中有记录<br />
$rs=mysql_query($sql);<br />
$num=@mysql_num_rows($rs);<br />
if(!($num>0))<br />
{<br />
echo "<script>alert('请登录后再进行操作。');location.href='index.php'</script>";<br />
}<br />
?><br />
[/php]<br />
登出部分，logout.php：<br />
[php]<br />
< ?php<br />
header("Content-Type: text/html; charset=utf-8");//不加这个，JS里的文字会乱码～<br />
setcookie('uname',time()-1);<br />
setcookie('upwd',time()-1);<br />
echo "<script>alert('退出成功');location.href='index.php'";<br />
?><br />
[/php]</p>
<h4  class="related_post_title">Some Related Posts</h4><ul class="related_post"><li>2009/11/24 -- <a  href="http://nwhy.org/as3-sharedobject-flash-cookie.html" title="AS3-SharedObject Flash的Cookie">AS3-SharedObject Flash的Cookie</a> (0)</li><li>2009/05/04 -- <a  href="http://nwhy.org/air-login-application.html" title="AIR-远程登录验证Login Check">AIR-远程登录验证Login Check</a> (0)</li><li>2009/04/15 -- <a  href="http://nwhy.org/php-easy-to-simulate-polymorphism.html" title="PHP-轻松实现多态">PHP-轻松实现多态</a> (2)</li><li>2009/03/26 -- <a  href="http://nwhy.org/php-web-client-snoopy.html" title="PHP-Web Client Class Snoopy">PHP-Web Client Class Snoopy</a> (1)</li><li>2009/03/25 -- <a  href="http://nwhy.org/as3-guestbook-doc.html" title="AS3-留言板制作全过程-实现篇">AS3-留言板制作全过程-实现篇</a> (26)</li><li>2009/03/18 -- <a  href="http://nwhy.org/apache-setting.html" title="Apache的域名配置和注意事项">Apache的域名配置和注意事项</a> (1)</li><li>2009/03/05 -- <a  href="http://nwhy.org/as-amfphp.html" title="AS-AMFPHP AS和AMFPHP的数据交互">AS-AMFPHP AS和AMFPHP的数据交互</a> (20)</li><li>2009/02/26 -- <a  href="http://nwhy.org/php-how-to-export-rss.html" title="PHP-输出RSS">PHP-输出RSS</a> (2)</li><li>2008/09/23 -- <a  href="http://nwhy.org/fckeditor-setting-php.html" title="Fckeditor详细配置-PHP版">Fckeditor详细配置-PHP版</a> (1)</li><li>2008/07/22 -- <a  href="http://nwhy.org/drupal-introduce.html" title="Drupal简介">Drupal简介</a> (2)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://nwhy.org/php-sign-cookie-logout.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
