当前位置:首页 » 编程语言 » php判断用户名

php判断用户名

发布时间: 2023-03-16 23:24:59

php 判断 用户名 英文或者数字

用正则来判断,如检查是否数字的代码: 1 2 if(preg_match("/^\d*$/",$fgid)) echo('是数字'); else echo('不是数字'); 验证由26个英文字母组成的字符串:^[A-Za-z]+$ 验证由26个大写英文字母组成的字符串:^[A-Z]+$ 验证由数字和26个英文字母组成的字符串:^[A-Za-z0-9]+$

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

使用sqlite数据库实现网页登录
客户端网页login.php
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<title>微博入口</title>
<styletype="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>
<scriptlanguage="javascript">
functioncheckfrm()
{
if(document.getElementById("txtuser").value=="")
{
window.alert("用户名不能为空!");
returnfalse;
}
if(document.getElementById("txtpwd").value=="")
{
window.alert("密码不能为空!");
returnfalse;
}
document.getElementById("frm1").action="funcexec.php";
//returntrue;
}
</script>
</head>

<body>
<formid="frm1"name="frm1"target="_self"method="post">
<div>
<pclass="tit">微博入口</p>
</div>
<hrclass="hin"/>
<div>
<tablewidth="309"border="0">
<tr>
<tdwidth="100"height="20"align="right"class="lab">用户名:</td>
<tdwidth="90"align="left"><labelfor="textfield"></label>
<inputname="txtuser"type="text"class="lab"id="txtuser"/></td>
</tr>
<tr>
<tdalign="right"class="lab">密&nbsp;&nbsp;&nbsp;码:</td>
<tdalign="left"><inputname="txtpwd"type="password"class="lab"id="txtpwd"/></td>
</tr>
<trclass="content">
<tdcolspan="2"align="center"><inputtype="submit"name="btn"id="btn"value="提交"onClick="checkfrm()"/></td>
</tr>
</table></div>
</form>

</body>
</html>
php程序判断func.php
<?php
session_start();
$conn=newPDO("sqlite:pic/maindata.db");
$login_sth=$conn->prepare("selectcount(*)astfromusertabwhereuid=?andpwd=?");
$article_sth=$conn->prepare("select*fromArticleList");
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("<ahref='index.php'>点击进入主页</a>");
}
else
echo("登陆失败");
}
else
{
echo("非法操作");
}
?>

⑶ PHP mysql判断用户名和密码匹配。

// 最原始的写法. 不能防止注入攻击, 学习的时候用一下可以. 正式项目不行
$sql = 'select * from DATA where ACNT="' . $username . '" and PSWD="' . $pass . '"';

热点内容
java返回this 发布:2025-10-20 08:28:16 浏览:578
制作脚本网站 发布:2025-10-20 08:17:34 浏览:872
python中的init方法 发布:2025-10-20 08:17:33 浏览:567
图案密码什么意思 发布:2025-10-20 08:16:56 浏览:751
怎么清理微信视频缓存 发布:2025-10-20 08:12:37 浏览:669
c语言编译器怎么看执行过程 发布:2025-10-20 08:00:32 浏览:995
邮箱如何填写发信服务器 发布:2025-10-20 07:45:27 浏览:240
shell脚本入门案例 发布:2025-10-20 07:44:45 浏览:99
怎么上传照片浏览上传 发布:2025-10-20 07:44:03 浏览:791
python股票数据获取 发布:2025-10-20 07:39:44 浏览:697