PHP用户名密码怎么判断啊,要连接数据库QAQ

2025-04-07 00:09:37
推荐回答(1个)
回答1:

使用sqlite数据库实现网页登录
客户端网页 login.php



微博入口

.tit {
font-size: 36px;
color: #06C;
font-style: normal;
text-align: center;
}
.lab {
font-size: 16px;
color: #069;
}
.hin {
width:98%;
size:3;
color:#33FF66;
}


function checkfrm()
{
if(document.getElementById("txtuser").value=="")
{
window.alert("用户名不能为空!");
return false;
}
if(document.getElementById("txtpwd").value=="")
{
window.alert("密码不能为空!");
return false;
}
document.getElementById("frm1").action="funcexec.php";
//return true;
}






微博入口






      
        用户名:
        
          
      
      
        密   码:
        
      
      
        
      
    


  


php程序判断 func.php
session_start();
$conn=new PDO("sqlite:pic/maindata.db");
$login_sth=$conn->prepare("select count(*) as t from usertab where uid=? and pwd=?");
$article_sth=$conn->prepare("select * from ArticleList");
if(isset($_POST["btn"]))
{
$uid=$_POST["txtuser"];
$pwd=$_POST["txtpwd"];
$login_sth->execute(array($uid,$pwd));
$tot=$login_sth->fetchAll();
if($tot[0][0]>0)
{
$_SESSION["userid"]=$uid;
echo("欢迎您,$uid");
echo("点击进入主页");
}
else
echo("登陆失败");
}
else
{
echo("非法操作");
}
?>