欧美亚洲中文,在线国自产视频,欧洲一区在线观看视频,亚洲综合中文字幕在线观看

      1. <dfn id="rfwes"></dfn>
          <object id="rfwes"></object>
        1. 站長(zhǎng)資訊網(wǎng)
          最全最豐富的資訊網(wǎng)站

          php 怎么實(shí)現(xiàn)用戶注冊(cè)登錄界面

          php實(shí)現(xiàn)用戶注冊(cè)登錄界面的方法:1、創(chuàng)建log.php登錄主界面;2、設(shè)置register.php注冊(cè)主界面;3、通過mysqli_connect連接數(shù)據(jù)庫并進(jìn)行相應(yīng)的數(shù)據(jù)操作即可。

          php 怎么實(shí)現(xiàn)用戶注冊(cè)登錄界面

          php入門到就業(yè)線上直播課:進(jìn)入學(xué)習(xí)
          Apipost = Postman + Swagger + Mock + Jmeter 超好用的API調(diào)試工具:點(diǎn)擊使用

          本教程操作環(huán)境:Windows7系統(tǒng)、PHP8.1版、Dell G3電腦。

          php 怎么實(shí)現(xiàn)用戶注冊(cè)登錄界面?

          PHP登錄與注冊(cè)頁面簡(jiǎn)單實(shí)現(xiàn)(包含數(shù)據(jù)庫驗(yàn)證)(包含數(shù)據(jù)庫)

          log.php(登錄主界面)

          由于是簡(jiǎn)單的頁面,登錄頁面只做了數(shù)據(jù)庫驗(yàn)證,其實(shí)有條件也可以加上郵箱驗(yàn)證和驗(yàn)證碼驗(yàn)證。

          php 怎么實(shí)現(xiàn)用戶注冊(cè)登錄界面

          <!doctype html> <html> <head> <meta charset="utf-8"> <title>無標(biāo)題文檔</title> </head> <style type="text/css"> #aaa{width: 300px; height: 30px;} </style> <body>     <center> <h2>登錄界面</h2>     <form method="POST" action="log_ok.php">        賬號(hào) :<input id="aaa" type="text" name="uname" placeholder="用戶名" />         <br /><br/>        密碼 :<input id="aaa"type="password" name="pwd" placeholder="密碼" />         <br />         <input type="submit" > <input type="reset"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="register.php">注冊(cè)賬號(hào)</a>     </form> </center> </body> </html>
          登錄后復(fù)制

          log_ok.php

          php 怎么實(shí)現(xiàn)用戶注冊(cè)登錄界面

          <!doctype html> <html> <head> <meta charset="utf-8"> <title>無標(biāo)題文檔</title> </head> <body> <?php header("content-type:text/html; charest=UTF-8");//文件編碼格式     // Session需要先啟動(dòng)。     session_start();     //判斷uname和pwd是否賦值     if(isset($_POST['uname']) && isset($_POST['pwd'])){         $name = $_POST['uname'];         $pwd = $_POST['pwd'];         //連接數(shù)據(jù)庫         require("conn.php");         if ($conn->connect_error) {             die("Connection failed: " . $conn->connect_error);         }         //驗(yàn)證內(nèi)容是否與數(shù)據(jù)庫的記錄吻合。         $sql = "SELECT * FROM register WHERE (account='$name') AND (password='$pwd')";         //執(zhí)行上面的sql語句并將結(jié)果集賦給result。         $result = $conn->query($sql);         //判斷結(jié)果集的記錄數(shù)是否大于0         if ($result->num_rows > 0) {                          // 輸出每行數(shù)據(jù)     ,,,不知道為什么在這個(gè)變量前設(shè)置字符串的時(shí)候,必須得用"",''這個(gè)是不實(shí)現(xiàn)的。。什么不使用也可以成功             while($row = $result->fetch_assoc()) { echo'歡迎'.$row['username'];                 echo '<p> 賬號(hào):' . $row['account'].'  <br/> 姓名:' . $row['username'].' <br/> 性別:' . $row['sex'].'      <br/> 年齡:' . $row['age'].'      <br/> 地址:' . $row['address'].'  <br/> 郵箱:' . $row['mail'].'     <br/> 電話:' . $row['number'].'   <br/> </p>';             }         } else {             echo "沒有您要的信息";         }         $conn->close();  //關(guān)閉數(shù)據(jù)庫          } ?> </body> </html>
          登錄后復(fù)制

          register.php(注冊(cè)主界面)

          這個(gè)頁面我設(shè)置了,隨機(jī)id,只要刷新頁面就會(huì)出現(xiàn)一個(gè)新的賬戶,但是由于我做的是個(gè)簡(jiǎn)單的,所以沒有實(shí)現(xiàn)id不重復(fù)。有條件,您可以實(shí)現(xiàn)一下,可以發(fā)給我互相交流下,另外,重復(fù)密碼驗(yàn)證我也沒有設(shè)置,這只是個(gè)簡(jiǎn)單的,您如果想的話,做出來給我發(fā)一份。哈哈。

          php 怎么實(shí)現(xiàn)用戶注冊(cè)登錄界面

          <!doctype html> <html> <head> <meta charset="utf-8"> <title>無標(biāo)題文檔</title> </head> <style type="text/css"> .aaa{width: 300px; height: 30px;} </style> <style type="text/javascript"> </style> <body> <?php  $a=mt_rand(333333,999999999); ?> <center> <h2>注冊(cè)界面</h2>  <form method="post" name="from1" action="register_ok.php"><!--  在數(shù)據(jù)庫中id是自動(dòng)增長(zhǎng)列  -->      賬號(hào):   <input name="id"  class="aaa" type="text" value="<?php echo"$a";?>"><br/><br/>          姓名: <input  class="aaa" type="text"  name="username"><br/><br/>      性別: <input  class="aaa" type="text"  name="sex"><br/><br/>      年齡: <input  class="aaa" type="text"  name="age"><br/><br/>      地址: <input  class="aaa" type="text"  name="address"><br/><br/>          郵箱: <input  class="aaa" type="text"  name="mail"><br/><br/>      密碼: <input  class="aaa" type="text"  name="password"><br/><br/> 確認(rèn)   密碼: <input  class="aaa" type="text"  name="repsw"><br/><br/>    手機(jī)號(hào):    <input   class="aaa"type="text"  name="number"><br/><br/>         <input type="reset"name="reset" value="重置"> <input type="submit"name="submit" value="注冊(cè)"  onClick="myfunction"> &nbsp;&nbsp;  <a href="log.php"><< 返回上一頁</a> <a href="register.php">點(diǎn)擊注冊(cè)</a> </form> </body> </html>
          登錄后復(fù)制

          register_ok.php

          php 怎么實(shí)現(xiàn)用戶注冊(cè)登錄界面

          <!doctype html> <html> <head> <meta charset="utf-8"> <title>無標(biāo)題文檔</title> </head> </body> <body> <?php include_once("conn.php"); header("content-type:text/html; charest=UTF-8");//文件編碼格式 $id=$_POST['id']; $username=$_POST['username']; $sex=$_POST['sex']; $age=$_POST['age']; $address=$_POST['address']; $mail=$_POST['mail']; $password=$_POST['password']; $number=$_POST['number']; if(!($id and $username and $sex and $age and $address and $mail and $password and $number)){ echo("輸入值不能為空");//判斷變量名是否為空值 }else{ $sqlstr1="insert into register values('".$id."','".$username."','".$sex."','".$age."','".$address."','".$mail."','".$password."','".$number."')"; //執(zhí)行sql   insert語句    把用post引用的變量接入到bookable中 $result = mysqli_query($conn,$sqlstr1);//承接結(jié)果集 if($result){ echo"添加成功"; }else{ echo"<script>alter('添加失敗');history.go(-1);</script>"; } } echo"$id $username $sex $age $address $mail $password $number"; ?> </body> </html>
          登錄后復(fù)制

          conn.php(連接數(shù)據(jù)庫)

          <!doctype html> <html> <head> <meta charset="utf-8"> <title>conn文件</title> </head> <body> <?php $mysql_server_name = 'localhost'; //改成自己的mysql數(shù)據(jù)庫服務(wù)器 $mysql_username = 'root'; //改成自己的mysql數(shù)據(jù)庫用戶名 $mysql_password = ''; //改成自己的mysql數(shù)據(jù)庫密碼 $mysql_database = 'regist'; //改成自己的mysql數(shù)據(jù)庫名 $conn=mysqli_connect($mysql_server_name,$mysql_username,$mysql_password,$mysql_database); //連接數(shù)據(jù)庫 //連接數(shù)據(jù)庫錯(cuò)誤提示 mysqli_query($conn, 'set names utf8'); mysqli_query($conn, 'set character set utf8'); if (mysqli_connect_errno($conn))  {  die("連接 MySQL 失敗: " . mysqli_connect_error());  } ?> </body> </html>
          登錄后復(fù)制

          數(shù)據(jù)庫

          1.數(shù)據(jù)庫名是regist

          2.表名是register

          php 怎么實(shí)現(xiàn)用戶注冊(cè)登錄界面

          推薦學(xué)習(xí):《PHP視頻教程》

          贊(0)
          分享到: 更多 (0)
          網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)