一个简单的登录界面代码及使用php写的后台数据库查询判断代码

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

一个简单的登录界面(login.php):divclass=containerid=show1style=margin-top:60px;text-align:center;divclass=form-grouphas-successformaction=confirm.phpmethod=post用户名:inputstyle=font-size:50px;height:100px;type=textname=nameclass=form-controlrequiredbr密码:inputstyle=font-size:50px;height:100px;type=passwordname=passwordclass=form-controlrequiredbrbuttonid=searchtype=submitclass=btnbtn-successstyle=width:600px;margin-top:10px;font-size:35px;登录/button/form/div/div帐号密码的数据库查询判断(confirm.php):?phpheader(Content-Type:text/html;charset=utf-8);//创建数据库链接:本地数据库,用户名:root,密码:空,数据库名称:test。$connect=mysqli_connect(localhost,root,,test);//定义变量并设置为空值$name=;if($_SERVER[REQUEST_METHOD]==POST){$name=test_input($_POST[name]);$password=test_input($_POST[password]);}functiontest_input($data){$data=trim($data);$data=stripslashes($data);$data=htmlspecialchars($data);return$data;}$flags=0;//从表admin中查询$result=mysqli_query($connect,SELECT*FROMadminwherename='.$name.');while($row=mysqli_fetch_array($result)){if($row['password']==$password){$flags=1;}}if($flags){mysqli_query($connect,UPDATEadminSETtimes=times+1WHEREname='.$name.');echoscriptalert('登陆成功!');window.location='index.php';/script;//跳转回首页(index.php)}else{echoscriptalert('密码或账号错误!');window.location='login.php';/script;//跳转回登录界面}//关闭数据库链接mysqli_close($connect);?

1 / 3
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功