login.php


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

<head>

   <link type="text/css" href="app.css" rel="stylesheet">

   <meta name="viewport" content="width=device-width; initial-scale=1.4;  minimum-scale=1.0; maximum-scale=2.0"/>

   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

   <title></title>

   <script type="text/javascript" language="JavaScript">

       function login(){

           var account=document.getElementById('account');

           var password=document.getElementById('password');



           if(account.value==""){


               alert("请输入帐号");

               account.focus;

               return;

           }


           if(password.value==""){

               alert("请输入密码");

               password.focus;

               return;

           }


           var xmlHttp;


           //创建XMLHttpRequest对象

           if(window.ActiveXObject){

               xmlHttp = new ActiveXObject("Microsoft.XmlHttp");

           } else if(window.XMLHttpRequest){

               xmlHttp = new XMLHttpRequest();

           }


           xmlHttp.onreadystatechange = function(){

               if(xmlHttp.readyState==4){



                   if(xmlHttp.status==200){

                       //发送到服务器之后返回的消息

                       document.getElementById('msg').innerHTML=xmlHttp.responseText;

                   }

               }

           }

           var url="test.php";

           var queryString="account=" + account.value;

           xmlHttp.open("post",url,true);

           xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");

           xmlHttp.send(queryString);



       }

   </script>

</head>


<body style="text-align: center">

<div class="appList"  >


   <table border="0" style="text-align: left" cellpadding="1" cellspacing="1" bordercolor="#AA7E7B">

       <tr>

           <td>

               帐号:

           </td>

           <td>

               <input id="account" type="text" maxlength="100" /><br/>

           </td>

       </tr>

       <tr>

           <td>

               密码

           </td>

           <td>

               <input id="password" type="password" maxlength="100" />

           </td>

       </tr>


   </table>

   <input  style="float: left" type="button" value="登录" οnclick="login()"/>


   <div id="msg"></div>

</div>

</body>

</html>



test.php


<?php


   if(isset($_REQUEST['account'])){

       echo "get account:".$_REQUEST['account'];

   }

?>