国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home Backend Development PHP Tutorial Detailed introduction to login, registration and password modification functions implemented in PHP

Detailed introduction to login, registration and password modification functions implemented in PHP

May 24, 2018 pm 04:33 PM

The example in this article describes how to implement login, registration and password modification functions in PHP. Share it with everyone for your reference, the details are as follows:
Here is the interface layout and function implementation of registration, login, and password change:
1. Login

Detailed introduction to login, registration and password modification functions implemented in PHP
2. Forgot password
Detailed introduction to login, registration and password modification functions implemented in PHP
3. Free registration
Detailed introduction to login, registration and password modification functions implemented in PHP
Page layout:

<p id="views" class="views">
  <p id="view-login" class="page-view view-login active">
    <present name="wxuser">
      <p id="wxuser" class="form-group text-center">
        <p>
          <img src="{sh:$wxuser.headimgurl}">
        </p>
        <h4 class="nickname">{sh:$wxuser.nickname}</h4>
      </p>
    </present>
    <!--登錄-->
    <p id="login" class="step">
      <h4 class="popup-title login">登錄</h4>
      <p class="go-forget">忘記密碼</p>
      <form class="form-horizontal" role="form" type="get">
        <p class="form-group">
          <label>手機號碼</label>
          <input type="tel" name="tel" class="form-item" id="tel_num" placeholder="請輸入手機號碼" value="">
        </p>
        <p class="form-group">
          <label>登錄密碼</label>
          <input type="password" name="password" class="form-item" placeholder="請?zhí)顚懨艽a">
        </p>
        <p class="js-help-info error"></p>
      </form>
      <p class="popup-options">
        <button type="button" class="btn btn-block btn-success js-login">確認</button>
      </p>
      <p class="go-register">免費注冊</p>
    </p>
    <!--注冊-->
    <p id="register" class="step" style="display:none;">
      <h4 class="popup-title">注冊賬號</h4>
      <form role="form" class="form-horizontal">
        <p class="form-group">
          <label>手機號碼</label>
          <input type="tel" name="tel" class="form-item" id="tel_num" placeholder="請輸入手機號碼" value="">
        </p>
        <p class="form-group form-group-r">
          <label>驗證碼</label>
          <button class="btn-sm btn-white js-sms-code" type="button">獲取驗證碼</button>
          <input type="text" placeholder="請?zhí)顚戲炞C碼" class="form-item" name="smscode" />
        </p>
        <p class="form-group">
          <label>登錄密碼</label>
          <input type="password" placeholder="設置登錄密碼" class="form-item" name="password" maxlength="30">
        </p>
        <p class="form-group">
          <label>確認密碼</label>
          <input type="password" placeholder="確認登錄密碼" class="form-item" name="re_password" maxlength="30">
        </p>
        <p class="js-help-info error">
        </p>
      </form>
      <p class="popup-options">
        <button type="button" class="btn btn-block btn-success js-register">確認</button>
      </p>
      <p class="go-login">立即登錄</p>
    </p>
    <!--修改密碼-->
    <p id="changePwd" class="step" style="display:none;">
      <h4 class="popup-title">修改密碼</h4>
      <form role="form" class="form-horizontal">
        <p class="form-group">
          <label>手機號碼</label>
          <input type="tel" name="tel" class="form-item" id="tel_num" placeholder="請輸入手機號碼" value="">
        </p>
        <p class="form-group form-group-r">
          <label>驗證碼</label>
          <button class="btn-sm btn-white js-sms-excode" type="button">獲取驗證碼</button>
          <input type="text" placeholder="請?zhí)顚戲炞C碼" class="form-item" name="smscode" />
        </p>
        <p class="form-group">
          <label>新密碼</label>
          <input type="password" placeholder="設置登錄密碼" class="form-item" name="password" maxlength="30">
        </p>
        <p class="form-group">
          <label>確認密碼</label>
          <input type="password" placeholder="確認登錄密碼" class="form-item" name="re_password" maxlength="30">
        </p>
        <p class="js-help-info error">
        </p>
      </form>
      <p class="popup-options">
        <button type="button" class="btn btn-block btn-success js-changePwd">確認</button>
      </p>
      <p class="go-login">立即登錄</p>
    </p>
  </p>
</p>

js processing:

<script type="text/javascript">
var tel = &#39;&#39;;
$(function() {
  var check = {
    checkPwd: function(password) {
      if (typeof password == &#39;undefined&#39; || password == &#39;&#39;) {
        return false;
      }
      return true;
    },
    checkSmscode: function(code) {
      if (typeof code == &#39;undefined&#39; || code == &#39;&#39;) {
        return false;
      }
      return true;
    },
    validTel: function(value) {
      return /^((\+86)|(86))?(1)\d{10}$/.test(&#39;&#39; + value);
    }
  }
  //登錄
  $(".js-login").click(function() {
    var tel = $("#login").find("input[name=&#39;tel&#39;]").val();
    if (!check.validTel(tel)) {
      $(&#39;.js-help-info&#39;).html(&#39;請輸入正確的手機號&#39;); //**提示下個頁面還有
      return false;
    }
    var password = $("#login").find("input[name=&#39;password&#39;]").val();
    if (!check.checkPwd(password)) {
      $(&#39;.js-help-info&#39;).html(&#39;請輸入密碼&#39;);
      return false;
    }
    $(&#39;.js-login&#39;).attr("disabled", "disabled");
    $.ajax({
      url: "{sh::U(&#39;Home/userLogin&#39;)}",
      type: &#39;POST&#39;,
      dataType: "json",
      data: {
        tel: tel,
        password: password
      },
      success: function(response) {
        if (response.result) {
          location.href = response.href;
        } else {
          setTimeout(function() {
            $(&#39;.js-login&#39;).removeAttr("disabled");
          }, 500);
          $(&#39;.js-help-info&#39;).html(response.error);
        }
      },
      error: function() {
        $(&#39;.js-help-info&#39;).html("請求失敗");
      }
    });
  });
  //注冊
  $(".js-register").click(function() {
    var tel = $("#register").find("input[name=&#39;tel&#39;]").val();
    if (!check.validTel(tel)) {
      $(&#39;.js-help-info&#39;).html(&#39;請輸入正確的手機號&#39;); //**提示下個頁面還有
      return false;
    }
    var password = $("#register input[name=&#39;password&#39;]").val();
    var smscode = $("#register input[name=&#39;smscode&#39;]").val();
    var re_password = $("#register input[name=&#39;re_password&#39;]").val();
    if (!check.checkSmscode(smscode)) {
      $(&#39;.js-help-info&#39;).html(&#39;請輸入驗證碼&#39;);
      return false;
    }
    if (!check.checkPwd(password)) {
      $(&#39;.js-help-info&#39;).html(&#39;請輸入登錄密碼&#39;);
      return false;
    }
    if (!check.checkPwd(re_password)) {
      $(&#39;.js-help-info&#39;).html(&#39;請輸入確認密碼&#39;);
      return false;
    } else if (password != re_password) {
      $(&#39;.js-help-info&#39;).html(&#39;兩次輸入的密碼不一致&#39;);
      return false;
    }
    $(&#39;.js-login&#39;).attr("disabled", "disabled");
    $.ajax({
      url: "{sh::U(&#39;Home/userRegister&#39;)}",
      type: &#39;POST&#39;,
      dataType: "json",
      data: {
        tel: tel,
        password: password,
        smscode: smscode
      },
      success: function(response) {
        if (response.result) {
          location.href = response.href;
        } else {
          setTimeout(function() {
            $(&#39;.js-login&#39;).removeAttr("disabled");
          }, 500);
          $(&#39;.js-help-info&#39;).html(response.error);
        }
      },
      error: function() {
        $(&#39;.js-help-info&#39;).html("請求失敗");
      }
    });
  });
  //發(fā)送驗證碼
  $(&#39;.js-sms-code&#39;).click(function() {
    var tel = $(&#39;#register #tel_num&#39;).val();
    if (!check.validTel(tel)) {
      $(&#39;.js-help-info&#39;).html(&#39;請輸入正確的手機號&#39;); //**提示下個頁面還有
      return false;
    }
    // 檢測是否已經(jīng)注冊
    $.ajax({
      url: "{sh::U(&#39;Home/checkTel&#39;)}",
      type: &#39;POST&#39;,
      dataType: "json",
      async: false,
      data: {
        tel: tel
      },
      success: function(json) {
        checkRes = json.status;
      },
      error: function(json) {
        $(&#39;.js-help-info&#39;).html("發(fā)送失敗");
      }
    });
    if (checkRes == 1) {
      $(&#39;.js-help-info&#39;).html("已是注冊用戶");return false;
    }
    if (checkRes == 3) {
      $(&#39;.js-help-info&#39;).html("錯誤的請求");return false;
    }
    $(this).attr("disabled", "disabled").html("<span style=&#39;color:#666&#39;><span id=&#39;countdown&#39;>60</span>s 后再試</span>");
    countdown();
    $.ajax({
      url: "{sh::U(&#39;Home/sendSmscode&#39;)}",
      type: &#39;POST&#39;,
      dataType: "json",
      data: {
        tel: tel
      },
      success: function() {},
      error: function() {
        $(&#39;.js-help-info&#39;).html("發(fā)送失敗");
      }
    });
  });
  //修改密碼
  $(&#39;.go-forget&#39;).click(function() {
    var tel = $(&#39;#login #tel_num&#39;).val();
    $("#login").hide();
    $("#register").hide();
    $("#changePwd").show();
    $("#changePwd #tel_num").val(tel).focus();
    $(&#39;.js-help-info&#39;).html(&#39;&#39;);
  });
  //免費注冊
  $(&#39;.go-register&#39;).click(function() {
    var tel = $(&#39;#login #tel_num&#39;).val();
    $("#login").hide();
    $("#changePwd").hide();
    $("#register").show();
    $("#register #tel_num").val(tel).focus();
    $(&#39;.js-help-info&#39;).html(&#39;&#39;);
  });
  //立即登錄
  $(&#39;#changePwd .go-login&#39;).click(function() {
    var tel = $(&#39;#changePwd #tel_num&#39;).val();
    $("#register").hide();
    $("#changePwd").hide();
    $("#login").show();
    $("#login #tel_num").val(tel).focus();
    $(&#39;.js-help-info&#39;).html(&#39;&#39;);
  });
  //立即登錄
  $(&#39;#register .go-login&#39;).click(function() {
    var tel = $(&#39;#register #tel_num&#39;).val();
    $("#register").hide();
    $("#changePwd").hide();
    $("#login").show();
    $("#login #tel_num").val(tel).focus();
    $(&#39;.js-help-info&#39;).html(&#39;&#39;);
  });
  $(&#39;.js-changePwd&#39;).click(function() {
    var tel = $("#changePwd").find("input[name=&#39;tel&#39;]").val();
    if (!check.validTel(tel)) {
      $(&#39;.js-help-info&#39;).html(&#39;請輸入正確的手機號&#39;); //**提示下個頁面還有
      return false;
    }
    var password = $("#changePwd input[name=&#39;password&#39;]").val();
    var smscode = $("#changePwd input[name=&#39;smscode&#39;]").val();
    var re_password = $("#changePwd input[name=&#39;re_password&#39;]").val();
    if (!check.checkSmscode(smscode)) {
      $(&#39;#changePwd .js-help-info&#39;).html(&#39;請輸入驗證碼&#39;);
      return false;
    }
    if (!check.checkPwd(password)) {
      $(&#39;#changePwd .js-help-info&#39;).html(&#39;請輸入新密碼&#39;);
      return false;
    }
    if (!check.checkPwd(re_password)) {
      $(&#39;#changePwd .js-help-info&#39;).html(&#39;請輸入確認密碼&#39;);
      return false;
    } else if (password != re_password) {
      $(&#39;#changePwd .js-help-info&#39;).html(&#39;兩次輸入的密碼不一致&#39;);
      return false;
    }
    $.ajax({
      url: "{sh::U(&#39;Home/changePwd&#39;)}",
      type: "POST",
      dataType: "json",
      data: {
        tel: tel,
        password: password,
        smscode: smscode
      },
      success: function(response) {
        if (response.result) {
          location.href = response.href;
        } else {
          setTimeout(function() {
            $(&#39;.js-login&#39;).removeAttr("disabled");
          }, 500);
          $(&#39;.js-help-info&#39;).html(response.error);
        }
      },
      error: function() {
        $(&#39;.js-help-info&#39;).html("請求失敗");
      }
    });
  });
  //發(fā)送短信修改密碼
  $(&#39;.js-sms-excode&#39;).click(function() {
    var tel = $(&#39;#changePwd #tel_num&#39;).val();
    if (!check.validTel(tel)) {
      $(&#39;.js-help-info&#39;).html(&#39;請輸入正確的手機號&#39;); //**提示下個頁面還有
      return false;
    }
    // 檢測是否已經(jīng)注冊
    $.ajax({
      url: "{sh::U(&#39;Home/checkTel&#39;)}",
      type: &#39;POST&#39;,
      dataType: "json",
      async: false,
      data: {
        tel: tel
      },
      success: function(json) {
        checkRes = json.status;
      },
      error: function(json) {
        $(&#39;.js-help-info&#39;).html("發(fā)送失敗");
      }
    });
    if (checkRes == 2) {
      $(&#39;.js-help-info&#39;).html("號碼尚未注冊");return false;
    }
    if (checkRes == 3) {
      $(&#39;.js-help-info&#39;).html("錯誤的請求");return false;
    }
    $(this).attr("disabled", "disabled").html("<span style=&#39;color:#666&#39;><span id=&#39;countdown&#39;>60</span>s 后再試</span>");
    countdown();
    $.ajax({
      url: "{sh::U(&#39;Home/sendSmsexcode&#39;)}",
      type: &#39;POST&#39;,
      dataType: "json",
      data: {
        tel: tel
      },
      success: function(data) {},
      error: function() {
        $(&#39;.js-help-info&#39;).html("請求失敗");
      }
    });
  });
});
function countdown() { // 遞歸 驗證碼倒計時
  setTimeout(function() {
    var time = $("#countdown").text();
    if (time == 1) {
      $(&#39;.js-sms-code&#39;).removeAttr("disabled");
      $(&#39;.js-sms-code&#39;).html("發(fā)送驗證碼");
      $(&#39;.js-sms-excode&#39;).removeAttr("disabled");
      $(&#39;.js-sms-excode&#39;).html("發(fā)送驗證碼");
    } else {
      $("#countdown").text(time - 1);
      countdown();
    }
  }, 1000);
}
</script>

php background Processing:

//用戶登錄
public function userLogin() {
  if(IS_AJAX && !$this->member) {
   $tel = $this->_post(&#39;tel&#39;, &#39;trim&#39;);
   $password = $this->_post(&#39;password&#39;, &#39;trim,md5&#39;);
   $member = M(&#39;Member&#39;)->where(array(&#39;tel&#39; => $tel))->find();
   if ($member && $member[&#39;password&#39;] === $password) {
    //檢測是否存在微信用戶需要綁定
    if ($member[&#39;wxuser_id&#39;] == 0 && $this->wxuser) {
     M(&#39;Member&#39;)->where(array(&#39;id&#39; => $member[&#39;id&#39;]))->save(array(&#39;wxuser_id&#39; => $this->wxuser_id));
    }
    $href = session(LASTREQUEST);
    session(MEMBER, $member[&#39;id&#39;]);
    session(LASTREQUEST, null);
    $this->ajaxReturn(array(&#39;result&#39; => true, &#39;href&#39; => $href ? $href : U(&#39;Member/index&#39;)));
   } else {
    if (empty($member)) {
     $this->ajaxReturn(array(&#39;result&#39; => false, &#39;error&#39; => &#39;手機號尚未注冊.&#39;));
    } else {
     $this->ajaxReturn(array(&#39;result&#39; => false, &#39;error&#39; => &#39;密碼不正確.&#39;));
    }
   }
  } else {
   $this->ajaxReturn(array(&#39;result&#39; => false, &#39;error&#39; => &#39;非法請求.&#39;));
  }
}
// 用戶退出
public function userLogout() {
  session(WXUSER, null);
  session(MEMBER, null);
  $this->success(&#39;退出成功&#39;,U(&#39;Store/Member/index&#39;));
}
// 用戶注冊
public function userRegister() {
  $tel = $this->_post(&#39;tel&#39;, &#39;trim&#39;);
  $password = $this->_post(&#39;password&#39;, &#39;trim,md5&#39;);
  $smscode = $this->_post(&#39;smscode&#39;, &#39;trim&#39;);
  $session_smscode = session($this->smscode);
  $user_exit = M(&#39;Member&#39;)->where(array(&#39;tel&#39; => $tel))->find();
  if (!preg_match("/1[3458]{1}\d{9}$/", $tel) && $user_exit) {
   $this->ajaxReturn(array(&#39;result&#39; => false, &#39;error&#39; => &#39;手機號不合法&#39;));
  }
  $memberModel = M(&#39;Member&#39;);
  // 檢測是否已注冊
  $member = $memberModel-> where(array(&#39;tel&#39; =>$tel,&#39;status&#39;=>1))->find();
  if (!empty($member)) {
   $this->ajaxReturn(array(&#39;result&#39; => false, &#39;error&#39; => &#39;已是注冊用戶&#39;));
  }
  if (time() > $session_smscode[&#39;time&#39;] || $smscode != $session_smscode[&#39;code&#39;]) {
   $this->ajaxReturn(array(&#39;result&#39; => false, &#39;error&#39; => &#39;驗證碼不正確&#39;)); //--調試,先把驗證功能關閉
  }
  $data = array(&#39;tel&#39; => $tel, &#39;password&#39; => $password, &#39;wxuser_id&#39; => intval($this->wxuser_id), &#39;addtime&#39; => time());
  $insert_id = $memberModel->add($data);
  if ($insert_id) {
   $href = session(LASTREQUEST);
   session(MEMBER, $insert_id); //*****只是一個id值
   $this->ajaxReturn(array(&#39;result&#39; => true, &#39;href&#39; => $href ? $href : U(&#39;Member/index&#39;)));
  } else {
   $this->ajaxReturn(array(&#39;result&#39; => false, &#39;error&#39; => &#39;操作失敗&#39;, &#39;msg&#39; => M(&#39;Member&#39;)->getError()));
  }
}
//用戶更改密碼
public function changePwd(){
  $tel = $this->_post(&#39;tel&#39;,&#39;trim&#39;);
  $password = $this ->_post(&#39;password&#39;,&#39;trim&#39;);
  $smscode = $this ->_post(&#39;smscode&#39;,&#39;trim&#39;);
  $session_smscode = session($this ->smscode);
  if (time() > $session_smscode[&#39;time&#39;] || $smscode != $session_smscode[&#39;code&#39;]) {
   $this->ajaxReturn(array(&#39;result&#39; => false, &#39;error&#39; => &#39;驗證碼不正確&#39;)); //--調試成功
  }
  $data = array(&#39;password&#39; => md5($password), &#39;addtime&#39; => time());
  $memberModel = M(&#39;Member&#39;);
  // 檢測是否已注冊
  $member = $memberModel-> where(array(&#39;tel&#39; =>$tel,&#39;status&#39;=>1))->find();
  if (empty($member)) {
   $this->ajaxReturn(array(&#39;result&#39; => false, &#39;error&#39; => &#39;號碼尚未注冊&#39;));
  }
  if ($memberModel->where(array(&#39;tel&#39;=> $tel))->save($data)) {
   $href = session(LASTREQUEST);
   session(MEMBER, $member[&#39;id&#39;]);
   $this->ajaxReturn(array(&#39;result&#39; => true, &#39;href&#39; => $href ? $href : U(&#39;Member/index&#39;)));
  } else {
   $this->ajaxReturn(array(&#39;result&#39; => false, &#39;error&#39; => &#39;操作失敗&#39;, &#39;msg&#39; => M(&#39;Member&#39;)->getError()));
  }
}
// ajax檢測號碼是否注冊
public function checkTel() {
  $tel = $this->_post(&#39;tel&#39;, &#39;trim&#39;);
  if (IS_AJAX && preg_match("/1[3458]{1}\d{9}$/",$tel)) {
   $memberModel = M(&#39;Member&#39;);
   $member = $memberModel->where(array(&#39;tel&#39;=>$tel,&#39;status&#39;=>1))->find();
   if (!empty($member)) {
    $this->ajaxReturn(array(&#39;status&#39; => 1, &#39;info&#39; => &#39;已注冊&#39;));
   } else {
    $this->ajaxReturn(array(&#39;status&#39; => 2, &#39;info&#39; => &#39;未注冊&#39;));
   }
  } else {
   $this->ajaxReturn(array(&#39;status&#39; => 3, &#39;info&#39; => &#39;錯誤的請求&#39;));
  }
}
//發(fā)送注冊驗證碼
public function sendSmscode() {
  session($this->smstime, null);
  $smstime = session($this->smstime);
  $tel = $this->_post(&#39;tel&#39;, &#39;trim&#39;);
  if (IS_AJAX && (!$smstime || time() > $smstime) && preg_match("/1[3458]{1}\d{9}$/",$tel)) {
   $smscode = rand(1000, 9999);
   //發(fā)送驗證碼
   require LIB_PATH . &#39;ORG/Taobao-sdk-php/TopSdk.php&#39;;
   $c = new TopClient;
   $c->appkey = &#39;23307560&#39;; // 原23294081
   $c->secretKey = &#39;21ef24dd4c51e20693c5db0983c433e7&#39;; // 原0402169f466d8fed780e7f07edd25177
   $req = new AlibabaAliqinFcSmsNumSendRequest;
   $req->setSmsType("normal");
   $req->setSmsFreeSignName("注冊驗證");
   $req->setSmsParam(&#39;{"code":"&#39;. $smscode .&#39;","product":"【多多助店寶】"}&#39;);
   $req->setRecNum("{$tel}");
   $req->setSmsTemplateCode("SMS_5056863");
   $resp = $c->execute($req);
   if(!$resp->code) {
    //設置發(fā)送限制時間
    session($this->smstime, time() + 50);
    //設置驗證碼5分鐘內有效
    session($this->smscode, array(&#39;code&#39; => $smscode, &#39;time&#39; => time() + 600));
   } else {
    //發(fā)送失敗寫入日志文件
    $log = date(&#39;Y-m-d H:i:s&#39;) . " 發(fā)送失敗 sub_code:{$resp->sub_code} sub_msg:{$resp->sub_msg}" . PHP_EOL;
    file_put_contents(RUNTIME_PATH . &#39;Log/smscode.log&#39;, $log, FILE_APPEND);
   }
   $this->ajaxReturn(array(&#39;result&#39; => !$resp->code));
  } else {
   $this->ajaxReturn(array(&#39;result&#39; => false, &#39;error&#39; => &#39;錯誤的請求&#39;));
  }
}
//發(fā)送修改密碼驗證碼
public function sendSmsexcode(){
  session($this->smstime, null);
  $smstime = session($this->smstime);
  $tel = $this->_post(&#39;tel&#39;, &#39;trim&#39;);
  if (IS_AJAX && (!$smstime || time() > $smstime) && preg_match("/1[3458]{1}\d{9}$/",$tel)) {
   $smscode = rand(1000, 9999);
   //發(fā)送驗證碼
   require LIB_PATH . &#39;ORG/Taobao-sdk-php/TopSdk.php&#39;;
   $c = new TopClient;
   $c->appkey = &#39;23307560&#39;; // 原23294081
   $c->secretKey = &#39;21ef24dd4c51e20693c5db0983c433e7&#39;; // 原0402169f466d8fed780e7f07edd25177
   $req = new AlibabaAliqinFcSmsNumSendRequest;
   $req->setSmsType("normal");
   $req->setSmsFreeSignName("變更驗證"); //短信簽名固定,不可以換其他字
   $req->setSmsParam(&#39;{"code":"&#39;. $smscode .&#39;","product":"【多多助店寶】"}&#39;);
   $req->setRecNum("{$tel}");
   $req->setSmsTemplateCode("SMS_5056861");
   $resp = $c->execute($req);
   if(!$resp->code) {
    //設置發(fā)送限制時間
    session($this->smstime, time() + 50);
    //設置驗證碼5分鐘內有效
    session($this->smscode, array(&#39;code&#39; => $smscode, &#39;time&#39; => time() + 600));
   } else {
    //發(fā)送失敗寫入日志文件
    $log = date(&#39;Y-m-d H:i:s&#39;) . " 發(fā)送失敗 sub_code:{$resp->sub_code} sub_msg:{$resp->sub_msg}" . PHP_EOL;
    file_put_contents(RUNTIME_PATH . &#39;Log/smscode.log&#39;, $log, FILE_APPEND);
   }
   $this->ajaxReturn(array(&#39;result&#39; => !$resp->code));
  } else {
   $this->ajaxReturn(array(&#39;result&#39; => false, &#39;error&#39; => &#39;錯誤的請求&#39;));
  }
}

Summary:
1. SMS verification is used to register and change passwords.
2. For security reasons, front-end ajax verification. The backend also performs validation.
3. The process is reasonable and can be switched freely.
4. Comprehensive functions, including login, registration, and password modification.

The above is a detailed introduction to the login, registration and password modification functions implemented by PHP. For more related content, please pay attention to the PHP Chinese website (www.miracleart.cn)!


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to get the current session ID in PHP? How to get the current session ID in PHP? Jul 13, 2025 am 03:02 AM

The method to get the current session ID in PHP is to use the session_id() function, but you must call session_start() to successfully obtain it. 1. Call session_start() to start the session; 2. Use session_id() to read the session ID and output a string similar to abc123def456ghi789; 3. If the return is empty, check whether session_start() is missing, whether the user accesses for the first time, or whether the session is destroyed; 4. The session ID can be used for logging, security verification and cross-request communication, but security needs to be paid attention to. Make sure that the session is correctly enabled and the ID can be obtained successfully.

PHP get substring from a string PHP get substring from a string Jul 13, 2025 am 02:59 AM

To extract substrings from PHP strings, you can use the substr() function, which is syntax substr(string$string,int$start,?int$length=null), and if the length is not specified, it will be intercepted to the end; when processing multi-byte characters such as Chinese, you should use the mb_substr() function to avoid garbled code; if you need to intercept the string according to a specific separator, you can use exploit() or combine strpos() and substr() to implement it, such as extracting file name extensions or domain names.

How do you perform unit testing for php code? How do you perform unit testing for php code? Jul 13, 2025 am 02:54 AM

UnittestinginPHPinvolvesverifyingindividualcodeunitslikefunctionsormethodstocatchbugsearlyandensurereliablerefactoring.1)SetupPHPUnitviaComposer,createatestdirectory,andconfigureautoloadandphpunit.xml.2)Writetestcasesfollowingthearrange-act-assertpat

How to split a string into an array in PHP How to split a string into an array in PHP Jul 13, 2025 am 02:59 AM

In PHP, the most common method is to split the string into an array using the exploit() function. This function divides the string into multiple parts through the specified delimiter and returns an array. The syntax is exploit(separator, string, limit), where separator is the separator, string is the original string, and limit is an optional parameter to control the maximum number of segments. For example $str="apple,banana,orange";$arr=explode(",",$str); The result is ["apple","bana

JavaScript Data Types: Primitive vs Reference JavaScript Data Types: Primitive vs Reference Jul 13, 2025 am 02:43 AM

JavaScript data types are divided into primitive types and reference types. Primitive types include string, number, boolean, null, undefined, and symbol. The values are immutable and copies are copied when assigning values, so they do not affect each other; reference types such as objects, arrays and functions store memory addresses, and variables pointing to the same object will affect each other. Typeof and instanceof can be used to determine types, but pay attention to the historical issues of typeofnull. Understanding these two types of differences can help write more stable and reliable code.

Using std::chrono in C Using std::chrono in C Jul 15, 2025 am 01:30 AM

std::chrono is used in C to process time, including obtaining the current time, measuring execution time, operation time point and duration, and formatting analysis time. 1. Use std::chrono::system_clock::now() to obtain the current time, which can be converted into a readable string, but the system clock may not be monotonous; 2. Use std::chrono::steady_clock to measure the execution time to ensure monotony, and convert it into milliseconds, seconds and other units through duration_cast; 3. Time point (time_point) and duration (duration) can be interoperable, but attention should be paid to unit compatibility and clock epoch (epoch)

How to pass a session variable to another page in PHP? How to pass a session variable to another page in PHP? Jul 13, 2025 am 02:39 AM

In PHP, to pass a session variable to another page, the key is to start the session correctly and use the same $_SESSION key name. 1. Before using session variables for each page, it must be called session_start() and placed in the front of the script; 2. Set session variables such as $_SESSION['username']='JohnDoe' on the first page; 3. After calling session_start() on another page, access the variables through the same key name; 4. Make sure that session_start() is called on each page, avoid outputting content in advance, and check that the session storage path on the server is writable; 5. Use ses

How does PHP handle Environment Variables? How does PHP handle Environment Variables? Jul 14, 2025 am 03:01 AM

ToaccessenvironmentvariablesinPHP,usegetenv()orthe$_ENVsuperglobal.1.getenv('VAR_NAME')retrievesaspecificvariable.2.$_ENV['VAR_NAME']accessesvariablesifvariables_orderinphp.iniincludes"E".SetvariablesviaCLIwithVAR=valuephpscript.php,inApach

See all articles