Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.90 KB | None | 0 0
  1. <?php
  2. //process_editAccount.php
  3. global $userdetails;
  4. global $user;
  5. if($_POST['editMail'] && !$_POST['checkE']) {
  6.     $design->error("Please confirm email changing.");
  7. }
  8.  elseif ($_POST['editMail'] && $_POST['checkE']) {
  9.     //check if password matches the one in the db
  10.      if(!$_POST['pass'])
  11.          $design->error("Please enter your password in order to change your email address.");
  12.  
  13.      $hash = md5 ( $userdetails->personal_code . $_POST['pass'] . $userdetails->personal_code );
  14.      if($hash != $userdetails->hash)
  15.          $design->error("Incorrect password.");
  16.      if($_POST['email'] == $userdetails->email)
  17.              $design->error("Please modify your email address in order to change it.");
  18.      $query = "UPDATE users set email = '" . $db->escape($_POST['email']) . "' WHERE id= $userdetails->id";
  19.      $db->execute($query);
  20.      $design->ok("You have successfully changed your email address.", "Edit Account", "/myAccount.html");
  21. }
  22. elseif ($_POST['editPass'] && !$_POST['checkP']) {
  23.     $design->error("Please confirm password changing.");
  24. }
  25. elseif ($_POST['editPass'] && $_POST['checkP']) {
  26.     if(!$_POST['oldpass'])
  27.         $design->error("You didn't enter your current password.");
  28.  
  29.     if (isset($_POST['newp1'])) {
  30.         if (!isset($_POST['newp2']))
  31.             $design->error("Please confirm your new password.");
  32.         if ($_POST['newp1'] != $_POST['newp2'])
  33.             $design->error("Your new password was not confirmed. Please re-enter it.");
  34.  
  35.         $newPrivateCode = $user->generate_private_code();
  36.         $newHash = $user->generate_has($_POST['newp1'], $newPrivateCode);
  37.         $query = $db->update("users", array("hash" => "'" . $newHash . "'", "personale_code" => "'" . $newPrivateCode . "'"), array("id" => $userdetails->id));
  38.         $db->execure($query);
  39.         $design->ok("Your password has been changed.", "Edit Account", "/myAccount.html");
  40.     }
  41.  
  42. }
  43.  
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement