jQuery ajax 无刷新登录完整代码

jQuery ajax 无刷新登录完整代码

 
jQuery ajax 无刷新登录完整代码_第1张图片
演示

 

JavaScript Code
  1.   

 

XML/HTML Code
  1. <div id='logindiv'>  
  2.       
  3.         <label>Username:label>  
  4.             <input name="username"  id="username" type="text">  
  5.         <label>Password:label>  
  6.             <input name="password" id="password" type="password">  
  7.             <input value="Submit" name="submit" class="submit" type="submit" onclick='chk_ajax_login_with_php();'>  
  8.         <div id='status'>div>  
  9. div>    

login.php

 

PHP Code
  1. include "conn.php";  
  2.   if($_POST){  
  3.     
  4.       $username=$_POST['username'];  
  5.       $password=md5($_POST['password']);  
  6.         
  7.        $sql=mysql_query("select * from username_list where username='$username' and password='$password'");  
  8.        $res=mysql_num_rows($sql);  
  9.          
  10.        if($res>0){  
  11.          
  12.           $rs_login=mysql_fetch_assoc($sql);  
  13.           $uid=$rs_login['user_id'];  
  14.           $_SESSION['sess_uid']=$uid;  
  15.           echo "success";  
  16.          
  17.        }else{  
  18.          
  19.          echo "invalid username or password";  
  20.          
  21.        }  
  22.    }  
  23.      
  24. ?>  

 

CSS Code
  1. * {  
  2.         margin0px;  
  3.         padding0px;outlinenone;  
  4.     }  
  5.   
  6.     #logindiv {  
  7.         border1px solid #270644;  
  8.         width250px;  
  9.         -moz-border-radius: 20px;  
  10.         -webkit-border-radius: 20px;  
  11.         background:  -moz-linear-gradient(19% 75% 90deg,#716D78#DFD2E8);  
  12.         background:-webkit-gradient(linear, 0% 0%, 0% 100%, from(#DFD2E8), to(#716D78));  
  13.         margin:50px auto;  
  14.         padding20px;  
  15.         -moz-box-shadow:0px -5px 300px #270644;  
  16.         -webkit-box-shadow:0px -5px 300px #270644;  
  17.     }  
  18.   
  19.     label {  
  20.         font-size12px;  
  21.         font-familyarialsans-serif;  
  22.         list-style-typenone;  
  23.         color#000;  
  24.         text-shadow#000 1px 1px;  
  25.         margin-bottom10px;  
  26.         font-weightbold;  
  27.         letter-spacing1px;  
  28.         text-transformuppercase;  
  29.         displayblock;  
  30.     }  
  31.   
  32.     input {  
  33.       -webkit-transition-property: -webkit-box-shadow, background;  
  34.       -webkit-transition-duration: 0.25s;  
  35.         padding6px;  
  36.         border-bottom0px;  
  37.         border-left0px;  
  38.         border-right0px;  
  39.         border-top1px solid #FFFFFF;  
  40.         -moz-box-shadow: 0px 0px 2px #000;  
  41.         -webkit-box-shadow: 0px 0px 2px #000;  
  42.         margin-bottom10px;  
  43.         background#EDE7F1;  
  44.         width230px;  
  45.     }  
  46.   
  47.     input.submit {  
  48.       -webkit-transition-property: -webkit-box-shadow, background;  
  49.       -webkit-transition-duration: 0.25s;  
  50.         width100px;  
  51.         background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#5E476F), to(#8B7999));     
  52.         background:  -moz-linear-gradient(19% 75% 90deg,#8B7999#5E476F);  
  53.         color#fff;  
  54.         text-transformuppercase;  
  55.         text-shadow#000 1px 1px;  
  56.         border-top1px solid #ad64e0;  
  57.         margin-top10px;  
  58.     }  

 


原文地址:http://www.freejs.net/article_biaodan_98.html

你可能感兴趣的:(jQuery ajax 无刷新登录完整代码)