omeganoova
Software Architect
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
200 XP
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.
Download
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.
- <div
style
=
"width:30%;"
>
- <form
method
=
"post"
action
=
"change-password.php"
>
- <div
>
- <label
style
=
"color:blue;"
>
Old Password</
label
>
- <input
type
=
"password"
name
=
"old_pass"
placeholder=
"Old Password . . . . ."
>
- </
div
>
- <div
>
- <label
style
=
"color:blue;"
>
New Password</
label
>
- <input
type
=
"password"
name
=
"new_pass"
placeholder=
"New Password . . . . ."
>
- </
div
>
- <div
>
- <label
style
=
"color:blue;"
>
Re-Type New Password</
label
>
- <input
type
=
"password"
name
=
"re_pass"
placeholder=
"Re-Type New Password . . . . ."
>
- </
div
>
- <button
type
=
"submit"
name
=
"re_password"
>
Submit</
button
>
- </
form
>
- </
div
>
Create Database Connection
This would be your database connection.
- <?php
- $database_connection
=
mysql_connect
(
"localhost"
,
"root"
,
""
)
or die
(
)
;
- $select_database
=
mysql_select_db
(
"change_password"
,
$database_connection
)
or die
(
)
;
- ?>
This is the PHP query where the UPDATE Statement is used to change the password from the database.
- <?php
- if
(
isset
(
$_POST
[
're_password'
]
)
)
- {
- $old_pass
=
$_POST
[
'old_pass'
]
;
- $new_pass
=
$_POST
[
'new_pass'
]
;
- $re_pass
=
$_POST
[
're_pass'
]
;
- $password_query
=
mysql_query
(
"select * from users where id='1'"
)
;
- $password_row
=
mysql_fetch_array
(
$password_query
)
;
- $database_password
=
$password_row
[
'password'
]
;
- if
(
$database_password
==
$old_pass
)
- {
- if
(
$new_pass
==
$re_pass
)
- {
- $update_pwd
=
mysql_query
(
"update users set password='$new_pass
' where id='1'"
)
;
- 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>"
;
- }
- }
- ?>
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.
Download
You must upgrade your account or reply in the thread to view the hidden content.