Guest User

Untitled

a guest
Mar 5th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include ('include/config.php');
  4. if(isset($_POST['change_password'])) {
  5.  
  6. $oldpassword = md5($_POST['oldpassword']);
  7. $newpassword = md5($_POST['newpassword']);
  8. $newpassword2 = md5($_POST['newpassword2']);
  9.  
  10.  
  11. $sql = "SELECT password FROM members WHERE username='$username' ";
  12. $stmt = $dbconnect->prepare($sql);
  13. $stmt->execute();
  14. $row = $stmt->fetch(PDO::FETCH_ASSOC);
  15. $oldpassworddb = $row['password'];
  16.  
  17. if ($oldpassword == $oldpassworddb)
  18. {
  19. if ($newpassword == $newpassword2)
  20. {
  21. $insert = "UPDATE members SET password=':newpassword' WHERE username='$username' ";
  22. $count = $dbconnect->prepare($insert);
  23. $count->execute(array(':newpassword' => $newpassword));
  24. echo " Your password has succesfully changed.";
  25. }
  26. else
  27. echo " Wrong Password. ";
  28. }
  29. }
  30.  
  31. ?>
  32. <html>
  33. <head>
  34. <title></title>
  35. </head>
  36. <body >
  37. <form method="POST" action="" >
  38. <table border="0">
  39.  
  40. <tr><td>Old Password </td><td><input type="text" name="oldpassword" size="20" /></td></tr>
  41.  
  42. <tr><td>New Password </td><td><input type="password" name="newpassword" size="20" /></td></tr>
  43.  
  44. <tr><td>Confirm New Password </td><td><input type="password" name="newpassword2" size="20" /></td></tr>
  45.  
  46. <tr><td></td><td><input type="submit" value="Change Password" name='change_password' /></td></tr>
  47.  
  48. </table>
  49. </form>
  50. </body>
  51. </html>
Add Comment
Please, Sign In to add comment