php和ajax结合实现登录
分类:热门资源

啊哈,终于用PHP达成了登陆和注册拉,可是难题又来了,供给用ajax和php结合落实登陆注册油烟机洗刷php登入源码:下边是chklogin.php页面代码:?phpsession_start();$connect=mysql_connect(127.0.0.1,root,123);if(!$connect){die(''Could not connect: '' . mysql_error());}mysql_select_db(design,$connect);$query=select * from ta_user where user_name =''.$name.'';$result=mysql_query($query) OR die(Unable to connect to MySQL);$rows=mysql_威尼斯正规官网,fetch_array($result);if($rows[user_password]==$pwd){header(Location:login_suss.php?name=.$name.State of Qatar;}else{echo table width=''235'' height=''61'' border=''0'' align=''center'';echo trtd height=''29''客商名或密码错误!/td/tr;echo trtd height=''29''请点击a href=''javascrīpt:history.go(-1卡塔尔国;''这儿/a重新输入!;echo /td/tr;echo /table;}?ajax:scrīpt language=javascrīptfunction getXMLHTTPRequest(卡塔尔(قطر‎{var xRequest=null;if (window.XMLHttpRequest卡塔尔(قطر‎{xRequest=new XMLHttpRequest(State of Qatar;}else if (typeof ActiveXObject != undefined){xRequest=new ActiveXObject(Microsoft.XMLHTTP);}return xRequest;}function Ajax(url){AjaxObj = getXMLHTTPRequest();AjaxObj.onreadystatechange = processRequest;AjaxObj.open(post,url,true);AjaxObj.setRequestHeader(''Content-type'',''application/x-'');AjaxObj.send(name+name);}function processRequest(){if(AjaxObj.readyState == 4){if(AjaxObj.status == 200){if(AjaxObj.responseText != 卡塔尔{document.getElementById(showState of Qatar.innerHTML=;//alert(AjaxObj.responseText卡塔尔(قطر‎;document.getElementById(show卡塔尔国.innerHTML=AjaxObj.responseText;}}else{alert(您所乞求的页面有不行。<

php ajax客商注册检查测量检验代码

index.php 复制PHP内容到剪贴板 PHP代码:tr td width=十分六class=altbg1nbsp;nbsp;用 户 名font color=red*/fontbr //td td input size=25 name=username type=text value= onBlur=startRequest(document.getElementById('username').value); / /td td id=ckuser/td /tr

js:ajax.js 复制PHP内容到剪贴板 var xmlHttp; function createXMLHttpRequest(卡塔尔 { if(window.XMLHttpRequestState of Qatar { xmlHttp = new XMLHttpRequest(卡塔尔国;//mozilla浏览器 } else if(window.ActiveXObject卡塔尔国 { try { xmlHttp = new ActiveX0bject(Msxml2.XMLHTTPState of Qatar;//IE老版本 } catch(e卡塔尔(قطر‎ {} try { xmlHttp = new ActiveXObject(Microsoft.XMLHTTP卡塔尔(قطر‎;//IE新版本 } catch(e卡塔尔{} if(!xmlHttp卡塔尔(قطر‎ { window.alert(不能够创立XMLHttpRequest对象实例State of Qatar; return false; } } } php ajax顾客注册检查测量试验代码 function startRequest(username卡塔尔国 { createXMLHttpRequest(卡塔尔(قطر‎;//特编 xmlHttp.open(GET,ckuser.php?name=+username,trueState of Qatar; xmlHttp.onreadystatechange = handleStateChange; xmlHttp.send(null卡塔尔; } function handleStateChange(卡塔尔(قطر‎ { if(xmlHttp.readyState==4卡塔尔国 { if(xmlHttp.status==200卡塔尔(قطر‎ { //alert(来自服务器的响应: + xmlHttp.responseText卡塔尔(قطر‎; if(xmlHttp.responseText == trueState of Qatar{ document.getElementById(ckuserState of Qatar.innerHTML = '此客户名以被人注册'; } else if(xmlHttp.responseText == falseState of Qatar { document.getElementById(ckuserState of Qatar.innerHTML = '检查测验通过'; } } } }

ckuser.php php ajax客商注册检验代码PHP代码:?php// //require_once globals.php; require_once config.inc.php; //require_once 'common/common.php'; $username = $_GET[name]; $con = @mysql_connect($dbserver,$dbuser,$dbpass 卡塔尔(قطر‎or die(不或然连接到数据库!); mysql_query(set names gbk); mysql_select_db($dbname,$con卡塔尔国or die(无法选用数据库!); $query=select id from hj_member where username='.$username.';; $res=mysql_query($query); if(mysql_num_rows($res)!=0) { echo true; }else { echo false; }

?

本文由威尼斯在线注册平台发布于热门资源,转载请注明出处:php和ajax结合实现登录

上一篇:头部加入如下代码,所以要先把搜索字节设置为1个字节 下一篇:威尼斯正规官网//定义允许上传的文件扩展名$ext
猜你喜欢
热门排行
精彩图文