當前位置:首頁 » 編程語言 » 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 瀏覽:539
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:826
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:529
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:712
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:632
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:944
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:201
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:61
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:754
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:657