当前位置:首页 » 编程语言 » 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 . '"';

热点内容
随机启动脚本 发布:2025-07-05 16:10:30 浏览:516
微博数据库设计 发布:2025-07-05 15:30:55 浏览:19
linux485 发布:2025-07-05 14:38:28 浏览:299
php用的软件 发布:2025-07-05 14:06:22 浏览:751
没有权限访问计算机 发布:2025-07-05 13:29:11 浏览:425
javaweb开发教程视频教程 发布:2025-07-05 13:24:41 浏览:687
康师傅控流脚本破解 发布:2025-07-05 13:17:27 浏览:234
java的开发流程 发布:2025-07-05 12:45:11 浏览:680
怎么看内存卡配置 发布:2025-07-05 12:29:19 浏览:277
访问学者英文个人简历 发布:2025-07-05 12:29:17 浏览:828