First find the pass.html page in the admin document and modify it to the pass.php file.
Then change the text "Change Member Password" to "Change Administrator Password".
After the modification, the following effect will be obtained:
After the modification is completed. The function can be realized. Let’s talk about the implementation process:
Use the database SQL statement to query whether the original password entered matches the password filled in the text box
If it matches, then If successful, the SQL statement modification function will be used to modify the password in the database
After the modification is successful, return to the login page and log in again with the new password.
The code is as follows:
<?php header("content-type:text/html;charset=utf-8"); include("config.php"); if($_POST){ $oldpassword = $_POST ["mpass"]; $newpassword = $_POST ["newpass"]; $confirm = $_POST['renewpass']; $sql1 = 'select password from admin where id=1 '; $result1 = mysqli_query($link,$sql1); $password = mysqli_fetch_assoc($result1)['password']; if ($oldpassword !== $password) { echo "<script>alert('原始密码不正确,请重新输入');</script>"; } else{ if ($newpassword==$confirm) { $sql2 = 'update admin set password ="'.$newpassword.'" where id =1'; mysqli_query($link,$sql2); echo "<script>alert('修改成功,请重新进行登陆!');window.location='login.html'</script>"; } } } ?>