婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁(yè) > 知識(shí)庫(kù) > PHP實(shí)現(xiàn)的用戶(hù)注冊(cè)表單驗(yàn)證功能簡(jiǎn)單示例

PHP實(shí)現(xiàn)的用戶(hù)注冊(cè)表單驗(yàn)證功能簡(jiǎn)單示例

熱門(mén)標(biāo)簽:銀川ai電話(huà)機(jī)器人 電梯外呼線路板維修視頻 芒果電銷(xiāo)機(jī)器人 上海公司外呼系統(tǒng)線路 浙江外呼電話(huà)系統(tǒng)軟件 臨沂智能電銷(xiāo)機(jī)器人軟件 十堰ai電話(huà)機(jī)器人效果怎么樣 地圖標(biāo)注風(fēng)向標(biāo) 安陽(yáng)自動(dòng)外呼系統(tǒng)價(jià)格是多少

本文實(shí)例講述了PHP實(shí)現(xiàn)的用戶(hù)注冊(cè)表單驗(yàn)證功能。分享給大家供大家參考,具體如下:

注冊(cè)界面

register.html

  h1>用戶(hù)注冊(cè)/h1>
  form method="post" action="register_verify.php">
    input type="text" placeholder="用戶(hù)名" name="username">br>br>
    input type="password" placeholder="密碼" name="password">br>br>
    input type="password" placeholder="重復(fù)密碼" name="password2">br>br>
    label>性別:
      input type="radio" name="sex" value="男" checked="checked">男
      input type="radio" name="sex" value="女">女/label>br>br>
    input type="email" placeholder="郵箱" name="email">br>br>
    button class="btn" type="submit">注冊(cè)/button>
  /form>

register_verify.php

?php
require "mysql.php";      //導(dǎo)入mysql.php訪問(wèn)數(shù)據(jù)庫(kù)
$username=$_POST['username'];
$password=$_POST['password'];
$password2=$_POST['password2'];
$sex=$_POST['sex'];
$email=$_POST['email'];
if(checkEmpty($username,$password,$password2,$sex,$email)){
  if(checkpwd($password,$password2)){
    if(checkEmail($email)){
      if(insert($username,$password,$sex,$email))
        echo"注冊(cè)成功";
    }
  }
}
//方法:判斷是否為空
function checkEmpty($username,$password,$password2,$sex,$email){
  if($username==null||$password==null||$password2==null){
    echo 'html>head>Script Language="JavaScript">alert("用戶(hù)名或密碼為空");/Script>/head>/html>'       . "meta http-equiv=\"refresh\" content=\"0;url=register.html\">";
  }
  else{
    if($sex==null){
      echo 'html>head>Script Language="JavaScript">alert("性別為空");/Script>/head>/html>' .          "meta http-equiv=\"refresh\" content=\"0;url=register.html\">";
    }
    elseif($email==null){
      echo 'html>head>Script Language="JavaScript">alert("郵箱為空");/Script>/head>/html>' .          "meta http-equiv=\"refresh\" content=\"0;url=register.html\">";
    }
    else{
      return true;
    }
  }
}
//方法:檢查兩次密碼是否相同
function checkpwd($password,$password2){
  if($password==$password2)
    return true;
  else
    echo 'html>head>Script Language="JavaScript">alert("兩次密碼不一致");/Script>/head>/html>' .        "meta http-equiv=\"refresh\" content=\"0;url=register.html\">";
}
//方法:郵箱格式驗(yàn)證
function checkEmail($email){
  $preg = '/^(\w{1,25})@(\w{1,16})(\.(\w{1,4})){1,3}$/';
  if(preg_match($preg, $email)){
    return true;
  }else{
    echo 'html>head>Script Language="JavaScript">alert("郵箱格式有誤");/Script>/head>/html>' .        "meta http-equiv=\"refresh\" content=\"0;url=register.html\">";
  }
}
//方法:將數(shù)據(jù)插入數(shù)據(jù)庫(kù)中
function insert($username,$password,$sex,$email){
  $conn=new Mysql();
  $sql="insert into user VALUE (null,'$username','$password','$sex','$email')";
  $result=$conn->sql($sql);
  if($result){
    return true;
  }
  else{
    echo 'html>head>Script Language="JavaScript">alert("寫(xiě)入數(shù)據(jù)庫(kù)失敗");/Script>/head>/html>' .        "meta http-equiv=\"refresh\" content=\"0;url=register.html\">";
  }
  $conn->close();
}

驗(yàn)證碼和數(shù)據(jù)庫(kù)的實(shí)現(xiàn)方法前面寫(xiě)過(guò),這里不再贅述。

可參考前面兩篇文章:

PHP封裝mysqli基于面向?qū)ο蟮膍ysql數(shù)據(jù)庫(kù)操作類(lèi)

PHP通過(guò)GD庫(kù)實(shí)現(xiàn)驗(yàn)證碼功能

PS:這里再為大家提供2款非常方便的正則表達(dá)式工具供大家參考使用:

JavaScript正則表達(dá)式在線測(cè)試工具:
http://tools.jb51.net/regex/javascript

正則表達(dá)式在線生成工具:
http://tools.jb51.net/regex/create_reg

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專(zhuān)題:《php程序設(shè)計(jì)安全教程》、《php安全過(guò)濾技巧總結(jié)》、《PHP基本語(yǔ)法入門(mén)教程》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門(mén)教程》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫(kù)操作入門(mén)教程》及《php常見(jiàn)數(shù)據(jù)庫(kù)操作技巧匯總》

希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。

您可能感興趣的文章:
  • PHP登錄驗(yàn)證功能示例【用戶(hù)名、密碼、驗(yàn)證碼、數(shù)據(jù)庫(kù)、已登陸驗(yàn)證、自動(dòng)登錄和注銷(xiāo)登錄等】
  • ubutu 16.04環(huán)境下,PHP與mysql數(shù)據(jù)庫(kù),網(wǎng)頁(yè)登錄驗(yàn)證實(shí)例講解
  • php使用sql server驗(yàn)證連接數(shù)據(jù)庫(kù)的方法
  • php驗(yàn)證用戶(hù)名是否以字母開(kāi)頭與驗(yàn)證密碼實(shí)例
  • php用戶(hù)注冊(cè)頁(yè)面利用js進(jìn)行表單驗(yàn)證具體實(shí)例
  • PHP+Ajax驗(yàn)證碼驗(yàn)證用戶(hù)登錄
  • php面向?qū)ο蟮挠脩?hù)登錄身份驗(yàn)證
  • PHP用戶(hù)驗(yàn)證和標(biāo)簽推薦的簡(jiǎn)單使用
  • 通過(guò)緩存數(shù)據(jù)庫(kù)結(jié)果提高PHP性能的原理介紹
  • PHP利用緩存處理用戶(hù)注冊(cè)時(shí)的郵箱驗(yàn)證,成功后用戶(hù)數(shù)據(jù)存入數(shù)據(jù)庫(kù)操作示例

標(biāo)簽:武威 遵義 荊門(mén) 遂寧 吐魯番 常州 寧夏 徐州

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《PHP實(shí)現(xiàn)的用戶(hù)注冊(cè)表單驗(yàn)證功能簡(jiǎn)單示例》,本文關(guān)鍵詞  PHP,實(shí)現(xiàn),的,用戶(hù)注冊(cè),表單,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《PHP實(shí)現(xiàn)的用戶(hù)注冊(cè)表單驗(yàn)證功能簡(jiǎn)單示例》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于PHP實(shí)現(xiàn)的用戶(hù)注冊(cè)表單驗(yàn)證功能簡(jiǎn)單示例的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 都匀市| 渭源县| 绍兴市| 来安县| 遂平县| 全椒县| 聊城市| 陆河县| 广昌县| 崇信县| 钟山县| 新巴尔虎右旗| 元朗区| 吴旗县| 普兰县| 大荔县| 自治县| 成都市| 定兴县| 临邑县| 屏南县| 寿宁县| 镇江市| 隆子县| 开封县| 沁水县| 东兰县| 肥西县| 合肥市| 克山县| 镶黄旗| 咸宁市| 英吉沙县| 剑河县| 裕民县| 乐亭县| 永嘉县| 原平市| 乐东| 文水县| 方正县|