Change Password by updating MySQL record using old and new password after validation in PHP
ฝัง
- เผยแพร่เมื่อ 8 ก.ย. 2024
- www.plus2net.c...
After login user can visit change password page, here user has to first enter old password and then enter new password to update records.
Our check.php page will check for the login status of the user and if not logged in them it will stop execution of the rest of the page. This will ensure that only logged in users can access to change password page.
Validation
We will check first whether the old password is matching against the users stored password in MySQL table.
We are using PHP Data Object to connect to MySQL database and collecting the password stored against the userid. Here we will be using userid available in session variable as the user is already logged in using userid and password.
We can check the length of the newly entered password and set the flag to off if they are not matching as per our requirement.
Both passwords ( new ) are to be same so we can compare them and check the validation.
If all these validations are cleared then we will use SQL update to replace old password with the new one. Before updating we will encrypt the password.
After successful execution of the update query we will display message to user saying that the password is changed.
Part 1 • HTML form input useri... Signup Form input validation
Part 2 • HTML form inserting us... Signup Form input storing in MySQL database
Part 3 • HTML form inserting us... Login and creating sessions
Part 4 • PHP login script to ch... Check session status and access control
Part 5 • Change Password by upd... Change Password
Part 6 • Update profile by user... Update Profile
Download source code as Zip file from
www.plus2net.c...
#changepassword #phpupdatepassword #updatenewpassword #validatepassword #validatebeforeupdate #plus2net #loginscript - วิทยาศาสตร์และเทคโนโลยี
cool