作者:Cika_用假名说真话 | 来源:互联网 | 2018-07-17 10:15
ec(2);啊哈,终于用PHP实现了登录和注册拉,但是问题又来了,要求用ajax和php结合实现登录注册油烟机清洗php登录源码:下面是chklogin.php页面代码:<?phpsession_start();$connectmysql_connect("127.0.0.1","root","123"
啊哈,终于用PHP实现了登录和注册拉,但是问题又来了,要求用ajax和php结合实现登录注册油烟机清洗
php登录源码:
下面是chklogin.php页面代码:
session_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."");
}
else
{
echo "
";
echo "用户名或密码错误! |
";
echo "请点击这儿重新输入!"; echo " |
";
echo "
";
}
?>
ajax:
function getXMLHTTPRequest()
{
var xRequest=null;
if (window.XMLHttpRequest)
{
xRequest=new XMLHttpRequest();
}
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-www-form-urlencoded'');
AjaxObj.send("name"+name);
}
function processRequest()
{
if(AjaxObj.readyState == 4)
{
if(AjaxObj.status == 200)
{
if(AjaxObj.responseText != "")
{
document.getElementById("show").innerHTML="";
//alert(AjaxObj.responseText);
document.getElementById("show").innerHTML=AjaxObj.responseText;
}
}
else
{
alert("您所请求的页面有异常。<