最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

基于PHP的登錄和注冊(cè)的功能的實(shí)現(xiàn)

 更新時(shí)間:2020年08月06日 16:33:26   作者:qq_29656961  
這篇文章主要介紹了基于PHP的登錄和注冊(cè)的功能的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

1.新建三個(gè)html文件,兩個(gè)php文件和若干個(gè)CSS文件和若干個(gè)JS文件

2.登錄的html頁面顯示效果圖


3.注冊(cè)的頁面的顯示效果圖

4.登錄頁面的form表單代碼

<div class="sign-con w1200">
			<img src="img/logn-tu.gif" class="sign-contu f-l"/>
			<form action="login.php" method="post">
				<div class="sign-ipt f-l">
					<p>用戶名:</p>
					<input type="text" name="username" placeholder="手機(jī)號(hào)/郵箱" />
					<p>密碼:</p>
					<input type="password" name="password" placeholder="密碼可見" />
					<br />
					<button class="slig-btn">登錄</button>
					<p>
						沒有賬號(hào)?請(qǐng)
						<a href="regist.html" rel="external nofollow" >注冊(cè)</a>
						<a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="wj">忘記密碼?</a>
					</p>
					<div class="sign-qx">
						<a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="f-r">
							<img src="img/sign-xinlan.gif" />
						</a>
						<a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="qq f-r">
							<img src="img/sign-qq.gif" />
						</a>
						<div style="clear: both;"></div>
					</div>
				</div>
			</form>
			<div style="clear: both;"></div>
		</div>

5.注冊(cè)頁面的form表單代碼

<div class="password-con registered">
			<form action="regist.php" method="post">
				<div class="psw">
					<p class="psw-p1">用戶名</p>
					<input type="text" name="username" placeholder="HR了" />
					<span class="dui"></span>
				</div>
				<div class="psw">
					<p class="psw-p1">輸入密碼</p>
					<input type="password" name="password" placeholder="請(qǐng)輸入密碼" />
					<span class="cuo">密碼由6-16的字母、數(shù)字、符號(hào)組成</span>
				</div>
				<div class="psw">
					<p class="psw-p1">確認(rèn)密碼</p>
					<input type="password" name="repassword" placeholder="請(qǐng)?jiān)俅屋斎朊艽a" />
					<span class="cuo">密碼不一致,請(qǐng)重新輸入</span>
				</div>
				<div class="psw psw2">
					<p class="psw-p1">手機(jī)號(hào)/郵箱</p>
					<input type="text" name="telphone" placeholder="請(qǐng)輸入手機(jī)/郵箱驗(yàn)證碼" />
					<button>獲取短信驗(yàn)證碼</button>
				</div>
				<div class="psw psw3">
					<p class="psw-p1">驗(yàn)證碼</p>
					<input type="text" placeholder="請(qǐng)輸入驗(yàn)證碼" />
				</div>
				<div class="yanzhentu">
					<div class="yz-tu f-l">
						<img src="img/psw-yanzhengtu.gif" />
					</div>
					<p class="f-l">
						看不清楚?
						<a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >換張圖</a>
					</p>
					<div style="clear: both;"></div>
				</div>
				<div class="agreement">
					<input type="checkbox" name="hobby" />
					<p>
						我有閱讀并同意
						<span>《宅客微購網(wǎng)站服務(wù)協(xié)議》</span>
					</p>
				</div>
				<button type="submit" value="注冊(cè)" class="psw-btn">立即注冊(cè)</button>
				<p class="sign-in">
					已有賬號(hào)?請(qǐng)
					<a href="login.html" rel="external nofollow" >登錄</a>
				</p>
			</form>
		</div><!-- 注冊(cè)框結(jié)束 -->

6.login.php代碼

<?php
  header("Content-type: text/html; charset=utf-8");
  $username = $_POST['username'];
  $password = $_POST['password'];
  $conn = new mysqli('localhost','root','root','shopping');
  if ($conn->connect_error){
    echo '數(shù)據(jù)庫連接失敗!';
    exit(0);
  }else{
    if ($username == ''){
      echo '<script>alert("請(qǐng)輸入用戶名!");history.go(-1);</script>';
      exit(0);
    }
    if ($password == ''){
      echo '<script>alert("請(qǐng)輸入密碼!");history.go(-1);</script>';
      exit(0);
    }
    $sql = "select username,password from userinfo where username = '$_POST[username]' and password = '$_POST[password]'";
    $result = $conn->query($sql);
    $number = mysqli_num_rows($result);
    if ($number) {
      echo '<script>window.location="index.html";</script>';
    } else {
      echo '<script>alert("用戶名或密碼錯(cuò)誤!");history.go(-1);</script>';
    }
  }
?>

7.regist.php代碼

<?php
  header("Content-type: text/html; charset=utf-8");
    $username = $_POST['username'];
    $password = $_POST['password'];
    $repassword = $_POST['repassword'];
    $telphone = $_POST['telphone'];
    if ($username == ''){
      echo '<script>alert("請(qǐng)輸入用戶名!");history.go(-1);</script>';
      exit(0);
    }
    if ($password == ''){
      echo '<script>alert("請(qǐng)輸入密碼");history.go(-1);</script>';
      exit(0);
    }
    if ($password != $repassword){
      echo '<script>alert("密碼與確認(rèn)密碼應(yīng)該一致");history.go(-1);</script>';
      exit(0);
    }
    if($password == $repassword){
      $conn = new mysqli('localhost','root','root','shopping');
      if ($conn->connect_error){
        echo '數(shù)據(jù)庫連接失敗!';
        exit(0);
      }else {
        $sql = "select username from userinfo where username = '$_POST[username]'";
        $result = $conn->query($sql);
        $number = mysqli_num_rows($result);
        if ($number) {
          echo '<script>alert("用戶名已經(jīng)存在");history.go(-1);</script>';
        } else {
          $sql_insert = "insert into userinfo (username,password,telphone) values('$_POST[username]','$_POST[password]','$_POST[telphone]')";
          $res_insert = $conn->query($sql_insert);
          if ($res_insert) {
            echo '<script>window.location="index.html";</script>';
          } else {
            echo "<script>alert('系統(tǒng)繁忙,請(qǐng)稍候!');</script>";
          }
        }
      }
    }else{
      echo "<script>alert('提交未成功!'); history.go(-1);</script>";
    }
?>

8.進(jìn)入首頁后的圖片


9.數(shù)據(jù)庫的圖片


到此這篇關(guān)于基于PHP的登錄和注冊(cè)的功能的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)PHP實(shí)現(xiàn)登錄和注冊(cè)的功能內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

萨迦县| 新化县| 五峰| 南投县| 辰溪县| 北辰区| 岑溪市| 丽水市| 青川县| 陵水| 四平市| 桐柏县| 澄迈县| 台中市| 云林县| 西城区| 泰顺县| 德清县| 滕州市| 西峡县| 新野县| 微山县| 黄石市| 青州市| 凌源市| 青龙| 宜川县| 金阳县| 湟源县| 新龙县| 浮梁县| 颍上县| 福海县| 甘泉县| 兴国县| 秦皇岛市| 内江市| 东台市| 昌吉市| 资溪县| 海原县|