Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.66 KB | None | 0 0
  1. <h2 style="text-align:center;">Change your password</h2>
  2. <br>
  3. <br>
  4. <form action="" method="post">
  5.  
  6. <table align="center" width="600" height="150">
  7.     <tr>
  8.         <td align="right"><b>Enter current password:</b></td>
  9.         <td><input type="password" name="current_pass" required></td>
  10.     </tr>
  11.    
  12.     <tr>
  13.         <td align="right"><b>Enter new password:</b></td>
  14.         <td><input type="password" name="new_pass" required></td>
  15.     </tr>
  16.    
  17.     <tr>
  18.         <td align="right"><b>Confirm your new password:</b></td>
  19.         <td><input type="password" name="new_pass_again" required></td>
  20.     </tr>
  21.  
  22.     <tr align="center">
  23.     <td colspan="8"><input type="submit" name="change_pass" value="Change password"/></td>
  24.     </tr>
  25.  
  26. </table>
  27.  
  28. </form>
  29.  
  30. <?php
  31.  
  32. include ("includes/db.php");
  33.  
  34. if(isset($_POST['change_pass'])){
  35.  
  36.     $user = $_SESSION['customer_email'];
  37.  
  38.     $current_pass = $_POST['current_pass'];
  39.     $new_pass = $_POST['new_pass'];
  40.     $new_again = $_POST['new_pass_again'];
  41.  
  42.     $sel_pass = "select * from customers where customer_pass='$old_pass'
  43.     AND customer_email='$user'";
  44.  
  45.     $run_pass = mysqli_query($con, $sel_pass);
  46.  
  47.     $check_pass = mysqli_num_rows($run_pass);
  48.  
  49.     if($check_pass==0){
  50.  
  51.         echo "<script>alert('Your current password is wrong!')</script>";
  52.         exit();
  53.  
  54.     }
  55.  
  56.     if($new_pass!=$new_again){
  57.  
  58.         echo "<script>alert('ERROR! Insert new password again')</script>";
  59.         exit();
  60.  
  61.     }
  62.  
  63.     else {
  64.  
  65.         $update_pass = "update customers set customer_pass='$new_pass'
  66.         where customer_email='$user'";
  67.  
  68.         $run_update = mysqli_query($con, $update_pass);
  69.  
  70.         echo "<script>alert('Your password has been updated!')</script>";
  71.         echo "<script>window.open('my_account.php','_self')</script>";
  72.  
  73.     }
  74.  
  75. }
  76.  
  77. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement