Ajax php user login example without refresh_PHP tutorial

WBOY
Release: 2016-07-13 16:55:03
Original
1050 people have browsed it





ajax php教程用户无刷新登录实例
<script><br> function userlogin(){<br>     var xmlhttp;<br>     var str;<br>     var sendstr="";<br>      try{<br>              xmlhttp=new xmlhttprequest();<br>          }<br>  catch(e){<br>              xmlhttp=new activexobject("microsoft.xmlhttp");<br>         }<br>  xmlhttp.onreadystatechange=function(){<br>           if (xmlhttp.readystate==4){<br>               if (xmlhttp.status==200){  <br>       str = xmlhttp.responsetext;  <br>       document.getelementbyid("userlogin").innerhtml=str; <br>       }else{<br>       alert("系统错误,如有疑问,请与管理员联系!"+xmlhttp.status);<br>     }<br>           }<br>        }<br>  xmlhttp.open("post","config/userlogin.php",true);<br>  xmlhttp.setrequestheader('content-type','application/x-www-form-urlencoded');<br>  xmlhttp.send(sendstr); <br>  }<br> </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 '用户名或密码不正确!';
  }
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/631707.htmlTechArticle!doctype html public -//w3c//dtd xhtml 1.0 transitional//en http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd html xmlns=http://www.w3.org/1999/xhtml head meta http-equiv=con...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!