【www.gdgbn.com--js教程】





ajax <a href="http://www.gdgbn.com/blist-7-1.html" target="_blank" class="keylink">php教程</a>用户无刷新登录实例
<script>
function userlogin(){
    var xmlhttp;
    var str;
    var sendstr="";
     try{
             xmlhttp=new xmlhttprequest();
         }
 catch(e){
             xmlhttp=new activexobject("microsoft.xmlhttp");
        }
 xmlhttp.onreadystatechange=function(){
          if (xmlhttp.readystate==4){
              if (xmlhttp.status==200){  
      str = xmlhttp.responsetext;  
      document.getelementbyid("userlogin").innerhtml=str; 
      }else{
      alert("系统错误,如有疑问,请与管理员联系!"+xmlhttp.status);
    }
          }
       }
 xmlhttp.open("post","config/userlogin.php",true);
 xmlhttp.setrequestheader("content-type","application/x-www-form-urlencoded");
 xmlhttp.send(sendstr);
 }
</script>



 


   
   


  输入用户名


 


   
 




userlogin.php文件

$uid = $_post["uname"];
$pwd = $_post["upwd"];
$sql ="select * from tabname where uid="$uid" and pwd="$pwd"";
$query = mysql教程_query( $sql );
if( mysql_num_rows( $query ) )
{
    echo "登录成功";
 }
 else
 {
     echo "用户名或密码不正确!";
  }
?>

本文来源:http://www.gdgbn.com/wangyezhizuo/28559/