亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

PHP develops simple book background management system password change function

We completed the administrator password modification page in the previous section

This section will implement this function

1622.png

##Need to give <input type = submit> ;Add an onClick event

Use javascript to determine the original password, new password, and confirm the new password. All of them must be empty. The new password and the confirmed password must be consistent.

<script type="text/javascript">
  function checkspace(checkstr) {
    var str = '';
    for(i = 0; i < checkstr.length; i++) {
      str = str + ' ';
    }
    return (str == checkstr);
  }
  function check()
  {
    if(checkspace(document.renpassword.password.value)) {
      document.renpassword.password.focus();
      alert("原密碼不能為空!");
      return false;
    }
    if(checkspace(document.renpassword.password1.value)) {
      document.renpassword.password1.focus();
      alert("新密碼不能為空!");
      return false;
    }
    if(checkspace(document.renpassword.password2.value)) {
      document.renpassword.password2.focus();
      alert("確認(rèn)密碼不能為空!");
      return false;
    }
    if(document.renpassword.password1.value != document.renpassword.password2.value) {
      document.renpassword.password1.focus();
      document.renpassword.password1.value = '';
      document.renpassword.password2.value = '';
      alert("新密碼和確認(rèn)密碼不相同,請重新輸入");
      return false;
    }
    document.admininfo.submit();
  }
</script>

Use the database SQL statement to query whether the original password entered matches the password filled in the text box

If the match is successful, the modification function of the SQL statement will be used to modify the password in the database After the password

is successfully modified, return to the login page and log in again using the new password.

<?php
$password=$_SESSION["pwd"];
$sql="select * from admin where password='$password'";
$rs=mysqli_query($link,$sql);
$rows=mysqli_fetch_assoc($rs);
$submit = isset($_POST["Submit"])?$_POST["Submit"]:"";
if($submit)
{
  if($rows["password"]==$_POST["password"])
  {
    $password2=$_POST["password2"];
    $sql="update admin set password='$password2' where id=1";
    mysqli_query($link,$sql);
    echo "<script>alert('修改成功,請重新進(jìn)行登陸!');window.location='login.php'</script>";
    exit();
  }
  else
    ?>
    <?php
  {
    ?>
    <script>
      alert("原始密碼不正確,請重新輸入")
      location.href="renpassword.php";
    </script>
    <?php
  }
}
?>


Continuing Learning
||
<script type="text/javascript"> function checkspace(checkstr) { var str = ''; for(i = 0; i < checkstr.length; i++) { str = str + ' '; } return (str == checkstr); } function check() { if(checkspace(document.renpassword.password.value)) { document.renpassword.password.focus(); alert("原密碼不能為空!"); return false; } if(checkspace(document.renpassword.password1.value)) { document.renpassword.password1.focus(); alert("新密碼不能為空!"); return false; } if(checkspace(document.renpassword.password2.value)) { document.renpassword.password2.focus(); alert("確認(rèn)密碼不能為空!"); return false; } if(document.renpassword.password1.value != document.renpassword.password2.value) { document.renpassword.password1.focus(); document.renpassword.password1.value = ''; document.renpassword.password2.value = ''; alert("新密碼和確認(rèn)密碼不相同,請重新輸入"); return false; } document.admininfo.submit(); } </script>
submitReset Code