1 <?php session_start();?>
2
3
4
5
6
login7
8
9
10
11 functionchkForm() {12 if(m$('username').value== "") {13
14 alert('用户名不能为空.');15 m$('username').focus();16 return false;17
18 }19 if(m$('password').value== "") {20
21 alert('密码不能为空.');22 m$('password').focus();23 return false;24
25 }26 if(m$('password').value!= "" &&m$('username').value!= "") {27
28 varxmlhttp=createRequest();29 if(xmlhttp) {30 m$('loading').innerHTML= "loading...";31 varusername=m$('username').value;32 varpwd=m$('password').value;33 varcode=m$('txtCode').value;34 varurl= "dologin.php";35 xmlhttp.open("POST", url,true);36 xmlhttp.onreadystatechange=ValidateResult;37 xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");38 xmlhttp.send("username=" +escape(username)+ "&password=" +escape(pwd)+ "&code=" +escape(code));39
40 }else{41 alert('xmlHttp创建失败.');42
43 }44
45 functionValidateResult() {46 if(xmlhttp.readyState== 4) {47 if(xmlhttp.status== 200) {48 if(xmlhttp.responseText!= "") {49
50 //window.alert(xmlhttp.responseText);
51 varobj=eval("(" +xmlhttp.responseText+ ")");52 if(obj.result== true) {53 alert("提示:" +obj.info);54 window.location= 'index.php';55
56 }else{57 alert("错误:" +obj.info);58
59 }60 }else{61 window.alert("从服务器获取失败");62
63 window.location.reload();64 }65 m$('loading').innerHTML= "";66 }67 }68
69 }70
71
72 }73
74 }75
76 functionm$(id) {77 returndocument.getElementById(id);78 }79
80 functionchangeCode() {81 varxmlhttp=createRequest();82 if(xmlhttp) {83 m$('loading').innerHTML= "loading...";84 vardt= newDate().getTime();85 //alert(dt);
86 varurl= "function/imagecode.php?dummay" +escape(dt);87 xmlhttp.open("GET", url,true);88 xmlhttp.onreadystatechange=ValidateResult;89 xmlhttp.send(null);90
91 }else{92 alert('xmlHttp创建失败.');93
94 }95
96 functionValidateResult() {97 if(xmlhttp.readyState== 4) {98 if(xmlhttp.status== 200) {99 vardt= newDate().getTime();100 varurl= "function/imagecode.php?dummay" +escape(dt);101 m$('imgCode').src= "function/imagecode.php?dummay" +escape(dt);102 m$('loading').innerHTML= "";103 }104 }105
106 }107 }108
109 functionshowTool() {110 $('#divToolTip').css("display","block");111 }112
113 functionhideTool() {114 $('#divToolTip').css("display","none");115 }116 window.οnlοad=initPage;117
118 functioninitPage() {119 $('#divToolTip').css("display","none");120 }121
122
123
124
125
126