Guest User

Untitled

a guest
Jan 15th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. <?php
  2.  
  3. require_once "/Configuration/config.php";
  4.  
  5. if (isset($_SESSION['username'])) {
  6. header('Location: home.php');
  7. }
  8.  
  9. /*Here you go you filthy old bandit! A small, simple yet functional password/email change script.*/
  10.  
  11. if(isset($_POST['p_submit'])) {
  12.  
  13. $password = $_POST['p_password']; // The Member's Current Password.
  14. $repassword = $_POST['p_repassword']; // The Member Must Confirm His Password.
  15. $nepassword = $_POST['p_nepassword']; // The Member's New Password.
  16.  
  17. if(!empty($password) && !empty($repassword) && !empty($nepassword)) {
  18.  
  19. if($password !== $repassword) {
  20.  
  21. mysql_query("UPDATE users SET password='".md5($nepassword)."' WHERE id='".$_SESSION['username']."' ")
  22. echo "Password successfuly changed."
  23.  
  24.  
  25. } else { echo "The passwords don't match. Please try again!"; }
  26.  
  27. } else { echo "Please fill in <b>all</b> fields."; }
  28.  
  29. }
  30.  
  31. if($_POST['e_submit']) {
  32.  
  33. $epassword = $_POST['e_password'];
  34. $erepassword = $_POST['e_repassword'];
  35. $email = $_POST['email'];
  36.  
  37. if(!empty($password) && !empty($repassword) && !empty($nepassword)) {
  38.  
  39. if($password !== $repassword) {
  40.  
  41. if(mysql_num_rows(mysql_query("SELECT * FROM users WHERE email='".$email."'")) > 0) {
  42.  
  43. mysql_query("UPDATE users WHERE id='".$_SESSION['username']."'");
  44. echo "Email successfuly updated."
  45.  
  46. } else { echo "Email is already being used. Please try with another one!"; }
  47.  
  48. } else { echo "Passwords doesn't match. Please try again!"; }
  49.  
  50. } else { echo "Please fill in <b>all</b> fields."; }
  51.  
  52. }
  53.  
  54. ?>
  55. <html>
  56. <body>
  57. <u>Password change.</u>
  58. <form action="settings.php" method="POST">
  59. <input type="text" name="password" placeholder="Your current password">
  60. <input type="text" name="repassword" placeholder="Retype your current password">
  61. <input type="text" name="nepassword" placeholder="Insert new password">
  62. <input type="submit" name="p_submit" value="Change password">
  63. </form><hr/>
  64. <u>Update email.</u>
  65. <form action="settings.php" method="POST">
  66. <input type="text" name="e_password" placeholder="Your current password">
  67. <input type="text" name="e_repassword" placeholder="Retype your current password">
  68. <input type="text" name="email" placeholder="Insert your new password">
  69. <input type="submit" name="e_submit" value="Change email">
  70. </form>
  71. </body>
  72. </html>
Add Comment
Please, Sign In to add comment