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

PHP没学过,今天老是突然要连接数据库登录,用户名密码正确显示网页,不正确显示信息有误,用那个wamp5自带的数据库,貌似叫mysql来着,弄了几个小时不会弄=-=

使用sqlite数据库实现网页登录
客户端网页 login.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>微博入口</title>
<style type="text/css">
.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;
}
</style>
<script language="javascript" >
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;
}
</script>
</head>

<body>
<form id="frm1" name="frm1" target="_self" method="post">
<div>
<p class="tit">微博入口</p>
</div>
<hr class="hin"/>
<div>
<table width="309" border="0" >
      <tr>
        <td width="100" height="20" align="right" class="lab" >用户名:</td>
        <td width="90" align="left"><label for="textfield"></label>
          <input name="txtuser" type="text" class="lab" id="txtuser" /></td>
      </tr>
      <tr>
        <td align="right" class="lab" >密&nbsp;&nbsp;&nbsp;码:</td>
        <td align="left"><input name="txtpwd" type="password" class="lab" id="txtpwd" /></td>
      </tr>
      <tr class="content">
        <td colspan="2" align="center"><input type="submit" name="btn" id="btn" value="提交"  onClick="checkfrm()"/></td>
      </tr>
    </table></div>
</form>
  
</body>
</html>
php程序判断 func.php
<?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("<a href='index.php'>点击进入主页</a>");
}
else
echo("登陆失败");
}
else
{
echo("非法操作");
}
?>

追问

那个。。。。我用的mysql数据库,就是那个wamp5自带的那个

温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网