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

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)密碼不相同,請(qǐng)重新輸入");
      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('修改成功,請(qǐng)重新進(jìn)行登陸!');window.location='login.php'</script>";
    exit();
  }
  else
    ?>
    <?php
  {
    ?>
    <script>
      alert("原始密碼不正確,請(qǐng)重新輸入")
      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)密碼不相同,請(qǐng)重新輸入"); return false; } document.admininfo.submit(); } </script>
submitReset Code