[2018-11-12]基于phpstudy制作简单ajax登录页面

参考自博主“让心开始”的文章https://www.cnblogs.com/cuikang/p/5260558.html,感觉例子基本功能有登陆交互了,简单明了,可以做参考,后面我这个懒虫慢慢改进吧。

先是index.html










    

    ajaxLogin

   

    







登录页面

用户名:

密  码:


然后到chuli.php


$uid=$_POST["uid"];

$pwd=$_POST["pwd"];

//数据库ip(放在服务器本地就直接localhost),数据库账号,数据库密码,你所用的数据库名称

$db=new mysqli("localhost","root","root","test");

if(mysqli_connect_error())

{

echo "连接错误";

}

else

{

//user2是用户信息所在的表,分别有username和password两项,需要对应起来

$sql="select count(*) from user2 where username='".$uid."' and password='".$pwd."'";

$result=$db->query($sql);

$row=$result->fetch_row();

if($row[0]==0)

{

echo "用户名或密码错误";

}

else

{

echo "OK";

}

}

?>

把这两个文件放在同一个文件夹,直接拖到phpstudy的WWW根目录下,然后试试在浏览器中访问,就可以了。

你可能感兴趣的:([2018-11-12]基于phpstudy制作简单ajax登录页面)