1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>无标题文档</title>
6 <script src="jq.js"></script>
7 </head>
8
9 <body>
10 <h1>登录</h1>
11
12 <div>用户名:</div>
13 <input type="text" id="uid" />
14 <div>密码:</div>
15 <input type="text" id="pwd" />
16 <input type="button" value="确定" id="dian" />
17
18 </body>
19 </html>
20 <script type="text/javascript">
21
22 $(document).ready(function(e) {
23 $("#dian").click(function(){
24
25 var uid=$("#uid").val();
26 var pwd=$("#pwd").val();
27
28 $.ajax({
29
30 url:"chuli.php",
31 data:{u:uid,p:pwd},
32 type:"POST",
33 dataType:"TEXT",
34 success: function(data){
35
36 if(data=="ok")
37 {
38 window.location="Main.php";
39
40 }
41 else
42 {
43 alert(data);
44 }
45
46 }
47
48 });
49
50
51 })
52
53 });
54
55
56
57
58 </script>
1 <?php
2
3 $uid=$_POST["u"];
4 $pwd=$_POST["p"];
5
6 include("DBDA.php");
7
8 $db=new DBDA();
9
10 $sql=" select count(*) from login where username='{$uid}'and password='{$pwd}'";
11 $attr=$db->Query($sql);
12 if($attr[0][0]==0)
13 {
14
15 echo "用户名密码不正确";
16 }
17 else
18 {
19 echo "ok";
20 }