How To Change Password Using PHP

Good Day!!!

In this tutorial, we are going to learn on How To Change Password Using PHP. In any Web Application, changing password is important feature. resultNow, let us create a change password using PHP script. database name - change_password old password : change_password

Directions:

For CSS Codes
For HTML Codes
Change Password
Old Password
New Password
Retype New Password

For PHP Codes
alert('Update Sucessfully'); window.location='index.php'"; } else{ echo ""; } } else { echo ""; }} ?>
Full Source Code
Change Password
Change Password alert('Update Sucessfully'); window.location='index.php'"; } else{ echo ""; } } else { echo ""; }} ?>
Old Password
New Password
Retype New Password

So what can you say about this work? Share your thoughts in the comment section below. Practice Coding. Thank you.

Comments

Submitted bySantu Chatterjee (not verified)on Tue, 04/11/2017 - 18:28

  1. <!DOCTYPE html>
  2. <title>Change Password</title>
  3. <style type="text/css">
  4. fieldset {
  5. width:500px;
  6. border:5px dashed #CCCCCC;
  7. margin:0 auto;
  8. border-radius:5px;
  9. }
  10.  
  11. legend {
  12. color: blue;
  13. font-size: 25px;
  14. }
  15.  
  16. dl {
  17. float: right;
  18. width: 390px;
  19. }
  20.  
  21. dt {
  22. width: 180px;
  23. color: brown;
  24. font-size: 19px;
  25. }
  26.  
  27. dd {
  28. width:200px;
  29. float:left;
  30. }
  31.  
  32. dd input {
  33. width: 200px;
  34. border: 2px dashed #DDD;
  35. font-size: 15px;
  36. text-indent: 5px;
  37. height: 28px;
  38. }
  39.  
  40. .btn {
  41. color: #fff;
  42. background-color: dimgrey;
  43. height: 38px;
  44. border: 2px solid #CCC;
  45. border-radius: 10px;
  46. float: right;
  47. }
  48.  
  49. </head>
  50.  
  51. <legend>Change Password</legend>
  52. <?php
  53. session_start();
  54. $getname=$_SESSION['user'];
  55. $conn_db = mysql_connect("localhost","root","") or die();
  56. $sel_db = mysql_select_db("diary",$conn_db) or die();
  57. if(isset($_POST['re_password']))
  58. {
  59. $old_pass=$_POST['old_pass'];
  60. $new_pass=$_POST['new_pass'];
  61. $re_pass=$_POST['re_pass'];
  62. $chg_pwd=mysql_query("select * from register where email='$getname'");
  63. $chg_pwd1=mysql_fetch_array($chg_pwd);
  64. $data_pwd=$chg_pwd1['password'];
  65. if($data_pwd==$old_pass){
  66. if($new_pass==$re_pass){
  67. $update_pwd=mysql_query("update register set password='$new_pass' where email='$getname'");
  68. echo "<script>alert('Update Sucessfully'); window.location='dailydiary.php'</script>";
  69. }
  70. else{
  71. echo "<script>alert('Your new and Retype Password is not match'); window.location='forgot.php'</script>";
  72. }
  73. }
  74. else
  75. {
  76. echo "<script>alert('Your old password is wrong'); window.location='forgot.php'</script>";
  77. }}
  78. ?>
  79.  
  80. <form method="post">
  81. <dl>
  82. <dt>
  83. Old Password
  84. </dt>
  85. <dd>
  86. <input type="password" name="old_pass" placeholder="Old Password..." value="" required />
  87. </dd>
  88. </dl>
  89. <dl>
  90. <dt>
  91. New Password
  92. </dt>
  93. <dd>
  94. <input type="password" name="new_pass" placeholder="New Password..." value="" required />
  95. </dd>
  96. </dl>
  97. <dl>
  98. <dt>
  99. Retype New Password
  100. </dt>
  101. <dd>
  102. <input type="password" name="re_pass" placeholder="Retype New Password..." value="" required />
  103. </dd>
  104. </dl>
  105.  
  106. <p align="center">
  107. <input type="submit" class="btn" value="Reset Password" name="re_password" />
  108. </p>
  109. </form>
  110. </body>
  111. </html>
Submitted bygeeza (not verified)on Fri, 05/19/2017 - 20:55

In reply to by Santu Chatterjee (not verified)

Thank you for posting it without numbers, obviously something the uploader cant do
Submitted byKashif (not verified)on Sun, 10/01/2017 - 20:13

This is not working mysqli.

Add new comment