0
回答
ext登录,跳不到主页,基本创建完session就不动了
科大讯飞通用文字识别100000次/天免费使用。立即申请   
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>后台登录</title>
    	<link rel="stylesheet" type="text/css"  href="../resources/css/ext-all.css" />
		<script type="text/javascript" src="../adapter/ext/ext-base.js"></script>
		<script type="text/javascript" src="../ext-all.js"></script>
		<script type="text/javascript" src="../src/locale/ext-lang-zh_CN.js"></script>
        <script type="text/javascript" src="cookie.js"></script>
    
</head>
<style type="text/css">
	body {
	background-color:#93b0cc;
}
#login-win .x-window-mc {
	background:#fff none;
	border:1px solid #eee;
}
#login-form .x-plain-body {
	color:#222;
	padding:10px;
	background:#FFFFFF none repeat scroll 0%;
	border:1px solid #99BBE8;
}
#login-win .x-window-body {
	background:#FFFFFF none repeat scroll 0%;
	border:1px solid #99BBE8;
}
.login-icon{
    background-image:url(images/icon/login-icon.gif) !important;
}
.user-icon{
    background:url(images/icon/User.gif)!important;background-repeat:no-repeat; 
background-position:right; 
;
}
.key-icon{
    background:url(images/icon/Key.gif)!important;no-repeat; 
background-position:right; 

}
.randcode-icon{
    background-image:url(images/icon/randcode-icon.gif) no-repeat 1px 2px;
}
.key-icon , .user-icon , .randcode-icon
{
	background-color:#FFFFFF;
	padding-left:20px;
	font-weight:bold;
	color:#000033;
}
</style>
<script language="javascript">
  
	var win_form = new Ext.FormPanel({
						id: 'login-form',
						name:'login-form',
						autoHeight: true,                  // 默认标签宽度板
                        labelAlign: 'right',
                        baseCls: 'x-plain',        //不设置该值,表单将保持原样,设置后表单与窗体完全融合(-_-!!,说不清了,大家可以去掉运行下看看)
                        bodyStyle: 'padding:5px 5px 0;',
                        width: 440,
                        frame: true,
                     	defaults: {
                                width: 150								
                            },
                        defaultType: 'textfield',//默认字段类型		
							items:[{
								   	xtype:'textfield',
									name: 'username',
									fieldLabel: '管理员名',
									allowBlank: false,
									icon: 'user-icon' ,
                   					style : "font-size: 15px" ,
									anchor:'80%',
									blankText: '用户名不能为空'
								   },
								   {
								    xtype:'textfield',
									name: 'password',
									fieldLabel: '密&nbsp;&nbsp;&nbsp;码',
									icon: 'key-icon' ,
                   					style : "font-size: 15px" ,
									anchor:'80%',
									inputType: "password",
									allowBlank: false,
									blankText: '密码不能为空' 
								   },
								   {
								    xtype:'textfield',
									id:'randCode',									
									fieldLabel: '验证码',
									iconcls: 'key-icon' ,
                   					style : "font-size: 15px" ,
									width:80,
									allowBlank: false,
									blankText : '验证码不能为空', 
									maxLength :4,
									minLength :4
								   }],
							buttonAlign: 'center',
						  	 buttons:[{
									text: "确定",
									handler: _login 
                        }, {
                            text: '重置',
                            handler: function(){
                               win_form.form.reset();		
                            }
                        }],
							keys:[{ 
							key:[10,13], 
							fn:_login 
     					 }]

		
		})
			function _login(){
                                if (win.getComponent('login-form').form.isValid()) {
									win.getComponent('login-form').form.submit({
												waitTitle: '请稍候',
												waitMsg: '正在登录,请稍候....',
												url: 'checklogin.php?action=login',
												method: 'POST',
                            
							 success: function(form, action){
                                            var Result = action.result.success;
                                            if (Result == 'false') {
                                                Ext.MessageBox.alert('提示', action.result.msg);
												   win_form.form.reset();
                                            }
                                            else 
                                                if (Result == 'true') {
													  location.href= action.result.url;
                                               			
                                                }
                                        },
                                        failure: function(form, action){
                                            Ext.MessageBox.alert('提示', action.result.msg);
                                            win_form.form.reset();
                                       		 }
                                        
                                   	 })
                               	 	
										  
										  
										  
								 }
                           		 }

var win= new Ext.Window({
						
						title: "登录窗口",
						width: 450,
						modal:true,
						AutoHeight:true,
						iconCls: 'login-icon' ,
						plain: true,			
						bodyStyle: 'padding:0px 0px 0;',
						resizeable: false,
						closable: false,
		       			draggable: false,
						
						items: [
									new Ext.Panel({ 
									id: 'loginLogo', 
									height: 60, 
									frame:false, 
									html:'<img src= "images/index.jpg" width="100%" height="95%"/>' 
									}), 
									win_form]
							})
	
Ext.onReady(function(){  
	Ext.QuickTips.init();
			win.show();
			var bd = Ext.getDom('randCode');     
			var bd2 = Ext.get(bd.parentNode);    
			bd2.createChild({tag: "img", id: "img-code", src: "checkNumber.php",align:"center",onclick:"reloadcode()" , alt:"点击可以刷新" ,style:"padding-left:5px"});
	})
	function reloadcode(){//刷新验证码函数
            var verify = document.getElementById('img-code');
            verify.setAttribute('src', 'checkNumber.php?' + Math.random());
}

  
	
</script>
<body>
</body>
</html>
处理页面
<?php
	include('conn.php');
	include('function.inc.php');
	@session_start();
	$action = $_GET['action'];
	switch ($action)
	{
		case 'login':	login();  break;
		case 'out':   out();break;
		case 'changepwd': changepwd();break;
		default: break;
	}
	function login()
	{
			
			$username = $_POST['username'];
			$password = $_POST['password'];
			$radio = $_POST['radio'];
			if ($radio == 'admin'){$url = 'index.php' ;}
			$sql="select *from user where user_name = '$username'";
			$res = mysql_query($sql);
			$row = mysql_fetch_array($res);
			
			if ($row['user_password'] == md5($password)){
				
					$_SESSION['rank'] = $row['rank'];
					$_SESSION['username'] = $username;
					$_SESSION['userid']=$row['user_id'];
					setlog('登录','');
					echo "{success:\"true\",msg:\"登录成功\",url:\"$url\"}"; 
			}else
			{
					echo "{success:\"false\",msg:\"用户名或密码错误!\"}";
			}
	}
	function out()
	{		
			setlog('退出','');
			unset ($_SESSION['username']);
			unset ($_SESSION['rank']);
			echo "{success:\"true\",msg:\"ok\"}";
	}
	function changepwd()
	{
			
			$username = $_SESSION['username'];
			$oldpassword = md5($_POST['oldpassword']);
			$newpassword =md5($_POST['newpassword']);
			$sql="select *from user where user_name = '$username'";
			$res = mysql_query($sql);
			$row = mysql_fetch_array($res);
			if ($row['user_password'] == $oldpassword){
					$sql="update user set user_password='$newpassword' where user_name = '$username'";
					$res = mysql_query($sql);
					if ($res) {
									echo "{success:\"true\",msg:\"ok\"}";
								}else{
									echo "{success:\"false\",msg:\"修改失败\"}";
								}
			}else
			{
					echo "{success:\"false\",msg:\"旧密码错误!\"}";
			}
	}
?>
举报
liao子鱼
发帖于6年前 0回/187阅
顶部