Update Password using PHP
Submitted by azalea zenith on Monday, October 3, 2016 - 15:15.
If you are looking for on how to Update Password u then you are at the right place. the right place. This simple tutorial creates using PHP/MySQL. The feature of this tutorial is to change the password from the database. It contains the Old Password from the database, New Password, and Re-Type New Password. Almost in web projects, changing password is important.
Create Markup Form
This simple HTML source code below contains three TextBox for the Old Password, New Password, and Re-Type Password. Where the user can update the password from the database. Review the source code below.
Create Database Connection
This would be your database connection.
This is the PHP query where the UPDATE Statement is used to change the password from the database.
Database Name: change_password.sql
Compile all the source code as you can see above to have this simple tutorial to change a password from the database or kindly click the "Download Code" button below for the full source code. Try and enjoy coding. Thank you.
- <div style="width:30%;">
- <form method="post" action="change-password.php">
- <div>
- <input type="password" name="old_pass" placeholder="Old Password . . . . .">
- </div>
- <div>
- <input type="password" name="new_pass" placeholder="New Password . . . . .">
- </div>
- <div>
- <input type="password" name="re_pass" placeholder="Re-Type New Password . . . . .">
- </div>
- </form>
- </div>
- <?php
- ?>
- <?php
- {
- $old_pass = $_POST['old_pass'];
- $new_pass = $_POST['new_pass'];
- $re_pass = $_POST['re_pass'];
- $database_password = $password_row['password'];
- if ($database_password == $old_pass)
- {
- if ($new_pass == $re_pass)
- {
- echo "<script>alert('Update Sucessfully'); window.location='index.php'</script>";
- }
- else
- {
- echo "<script>alert('Your new and Retype Password is not match'); window.location='index.php'</script>";
- }
- }
- else
- {
- echo "<script>alert('Your old password is wrong'); window.location='index.php'</script>";
- }
- }
- ?>
Add new comment
- 7647 views