導航:首頁 > 編程語言 > php服務發現與注冊

php服務發現與注冊

發布時間:2023-12-07 14:32:59

php實現手機驗證碼驗證注冊功能的邏輯是怎樣的

手機注冊驗證邏輯是這樣的:
首先要找簡訊服務商如:夢網、雲信使、互億無線等等申請簡訊發送介面。
網站實現流程如下:

第一步:用戶注冊時輸入手機號,網站首先要通過JS或者ajax+php驗證這個號碼是不是正確的手機號。
第二步:用戶點擊發送手機驗證碼,通過ajax把手機號傳到php,這時php生成一個隨機的驗證碼保存在session中,然後通過簡訊介面把這個驗證碼發送到這個手機號中。
第三步:用戶輸入手機收到的驗證碼注冊。網站用session中的驗證碼和用戶輸入的驗證碼比較。

❷ 怎麼用php實現手機注冊和手機驗證

在網路找個簡訊服務提供商,大概0.5分一條,這種穩定些。30秒以內收到。驗證就和驗證碼一樣處理了。

❸ 用PHP做登陸注冊頁面

登錄頁:login.php
<?php
include("conn.php");
$username=$_POST['name'];
$password=$_POST['password'];
$yanzheng=$_POST['yanzheng'];

if(isset($_POST['submit']))
{
$sql=("select username,password from member where username='$username' and password='$password'") or die("sql語句執行失敗");
//print_r($sql);
$ar=mysql_query($sql);
if($ar)
{
if($row=mysql_fetch_array($ar))
{
session_start();
if($_POST["yanzheng"])
{
if($yanzheng!=$_session[pic]||$yanzheng=="")
{
echo "驗證碼輸入有誤";
exit;
}
if($yanzheng==$_session[pic])
{
header("location:index.php");
}
}
}
else
{
echo "用戶名或密碼錯誤";
}
}
}

?>

<form action="login.php" method="post">
<table border=1 align=center width=500 height=300 bgColor=#DFFFDF bordercolor=#fffbec>
<tr>
<td colspan=2 align=center>用戶登錄</td>
</tr>
<tr>
<td>用戶姓名:</td>
<td><input type="text" name="name" id="name"/></td>
</tr>
<tr>
<td>用戶密碼:</td>
<td><input type="password" name="password" id="password"/></td>
</tr>
<tr>
<td>驗證碼:</td>
<td><input type="text" name="yanzheng" id="yanzheng"/>
<img src="yanzheng1.php" width="50" height="30"></img>
</td>
</tr>
<tr>
<td colspan=3 align=center>
<input type="submit" name="submit" value="登錄"/>
<input type="reset" name="reset" value="重置"/>
<a href="register.php">注冊</a>
</td>
</tr>
</table>
</form>

注冊頁:register.php

<?php
include("conn.php");
if(isset($_POST['submit'])&&$_POST['submit']) {
if($_POST['username']=='')
{
echo "用戶名不能為空";
exit();
}
if($_POST['password']=='')
{
echo "密碼不能為空";
exit();
}
if($_POST['realpass']!=$_POST['password'])
{
echo "兩次密碼輸入不一致";
exit();
}

$sql="insert into member(username,real_name,password,email,headimg) values('$_POST[username]','$_POST[username]','$_POST[password]','$_POST[email]','')";
$ar=mysql_query($sql);
if($ar)
{
header("location:index.php");
}
else
{
echo mysql_error();
}
}
?>
<body>
<form action="register.php" method="post">
<table border=1 align=center width=500>
<tr>
<td height=40 bgColor=#DFFFDF colspan=2>會員注冊 [<a href="login.php">返回登錄頁</a>]</td>
</tr>
<tr>
<td height=40 bgColor=#fffbec >會員ID</td>
<td><input type="text" name="username" id="username"/></td>
</tr>
<tr>
<td height=40 bgColor=#fffbec>密碼</td>
<td><input type="password" name="password" id="password"/></td>
</tr>
<tr>
<td height=40 bgColor=#fffbec>確認密碼</td>
<td>
<input type="password" name="realpass" id="realpass"/>
</td>
</tr>
<tr>
<td height=40 bgColor=#fffbec>EMAIL</td>
<td><input type="text" name="email" id="email"/>

</tr>
<tr>
<td height=40 bgColor=#fffbec></td>
<td><input type="submit" name="submit" value="注冊"/><input type="reset" value="重置"></td>
</tr>
</table>
</form>
</body>

主頁顯示:index.php
<?php
include("conn.php");
function cutstr($str,$cutleng)
{
$str = $str; //要截取的字元串
$cutleng = $cutleng; //要截取的長度
$strleng = strlen($str); //字元串長度
if($cutleng>$strleng)return $str;//字元串長度小於規定字數時,返回字元串本身
$notchinanum = 0; //初始不是漢字的字元數
for($i=0;$i<$cutleng;$i++)
{
if(ord(substr($str,$i,1))<=128)
{
$notchinanum++;
}
}
if(($cutleng%2==1)&&($notchinanum%2==0)) //如果要截取奇數個字元,所要截取長度范圍內的字元必須含奇數個非漢字,否則截取的長度加一
{
$cutleng++;
}
if(($cutleng%2==0)&&($notchinanum%2==1)) //如果要截取偶數個字元,所要截取長度范圍內的字元必須含偶數個非漢字,否則截取的長度加一
{
$cutleng++;
}
return substr($str,0,$cutleng);
}
?>
<html>
<head>
<script type="text/javascript">
function All(e, itemName)
{
var aa = document.getElementsByName(itemName);
for (var i=0; i<aa.length; i++)
aa[i].checked = e.checked; //得到那個總控的復選框的選中狀態
}
function Item(e, allName)
{
var all = document.getElementsByName(allName)[0];
if(!e.checked) all.checked = false;
else
{
var aa = document.getElementsByName(e.name);
for (var i=0; i<aa.length; i++)
if(!aa[i].checked) return;
all.checked = true;
}
}
</script>
</head>
<?php
include("conn.php");
if(isset($_POST['del']))
{
$mm = $_POST["selected"];
$id =implode(",",$mm);
$sql = "delete from forums where id in(".$id.")";
//echo $sql;
$result=mysql_query($sql);
echo $result?"刪除成功":"刪除失敗";
}
?>
<table style="BORDER-BOTTOM-WIDTH: 1px; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=600 align=center border=1 bordercolor=#ddddff>
<tr align=middle>
<td height=40 bgColor=#DFFFDF colspan=3>論壇列表</td>
</tr>
<tr>
<td colspan=3><a href="login.php" style="float:right">[退出系統]</a><a href="add_forum.php" style="float:right">[添加論壇]</a></td>
<td></td>
</tr>
<tr align=middle>
<td height=40 bgColor=#DFFFDF width=80>狀態</td>
<td height=40 bgColor=#DFFFDF>論壇</td>
<td height=40 bgColor=#DFFFDF>最後更新</td>
</tr>
<?php
$sql="select * from forums";
$result=mysql_query($sql);
$num=mysql_num_rows($result);
if($num>0)
{
while($row=mysql_fetch_array($result)){
?>
<tr align=middle>
<td bgColor=#fffbec><input type="checkbox" name="selected" value="1"/></td>
<td height=50 bgColor=#fffbec width=300>
<?php
echo "<div><a href=\"forums.php?F=".$row['ID']."\">".$row['forum_name']."</a></div>";
echo cutstr($row['forum_description'],24);//最多顯示24個位元組,12個字,多餘部分用省略號代替
echo "……";
?>
</td>
<td height=50 bgColor=#fffbec><div><?php echo $row['last_post_time']."by".$row['last_post_author']?></div></td>

</tr>
<?php
}
}
else
{
echo "<tr bgColor=#fffbec><td colspan=3>對不起,論壇尚在創建中……</td></tr>";
}
?>
<tr>
<td colspan=3> <input type="checkbox" name="selected" value="1" onclick="All(this,'selected')"/>全選/不全選</td>
</tr>
<tr>
<td><input type="button" name="del" id="del" value="刪除選中項"/>
<?php

?>
</td>
</tr>
</table>
</html>

資料庫你就自己建,望採納~

❹ 用php的CI框架怎麼寫登錄和注冊

在view里寫login.php,在controller里寫插入資料庫的代碼,同時調用。

閱讀全文

與php服務發現與注冊相關的資料

熱點內容
顯示加密服務超時 瀏覽:610
日語口譯pdf 瀏覽:432
外人如何評價身邊的程序員 瀏覽:105
霍夫曼編碼壓縮演算法 瀏覽:122
我想學習單片機 瀏覽:644
陳寶蓮拍過 瀏覽:336
遙調命令的設定命令實現過程 瀏覽:76
演算法中最壞情況都為多少 瀏覽:995
排序演算法圖形化展示 瀏覽:782
看電影免費網站入口 瀏覽:447
加密U盤啟動區和交換區格式化 瀏覽:247
求不需要下載播放器就能看的網站 瀏覽:828
日本重生電影在線 瀏覽:623
女的被一個小孩上了 瀏覽:948
macandroid找不到設備 瀏覽:514
漫威電影不能投屏了怎麼破 瀏覽:308
安卓qq最新版本怎麼解綁手機號 瀏覽:681
經典三極3d版古裝劇 瀏覽:172
phpcurljsonget 瀏覽:913
郝萬山pdf 瀏覽:86