vdp

Untitled

vdp
Jul 31st, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.96 KB | None | 0 0
  1. <form action="" method="post" >
  2.     <table width="700" border="0">
  3.         <tr>
  4.             <td align="left">  Current Password : </h3> </td>
  5.             <td align="left"> <input class="form-control"  type="password" name="old_pass" required /></td>
  6.         </tr>
  7.  
  8.         <tr>
  9.             <td align="left">  Enter New Password : </h3> </td>
  10.             <td align="left"> <input class="form-control"  type="password" name="new_pass" required /></td>
  11.         </tr>
  12.  
  13.         <tr>
  14.             <td align="left">  Confirm New Password: </h3> </td>
  15.             <td align="left"> <input  class="form-control" type="password" name="new_pass_again" required /></td>
  16.         </tr>
  17.  
  18.         <tr align="center">
  19.             <td colspan="4"><br><input class="btn btn-success" type="submit" name="change_pass" value="Change Password"/></td>
  20.         </tr>
  21.     </table>
  22. </form>
  23.  
  24. <?php
  25. include("../includes/db.php");
  26.  
  27.     $current_user=$_SESSION['customer_email'];
  28.     //validating password
  29.     if(isset($_POST['change_pass'])) //if user clicks change pass
  30.     {
  31.         $old_pass=$_POST['old_pass'];
  32.  
  33.         $new_pass = $_POST['new_pass'];
  34.         $new_pass_again=$_POST['new_pass_again'];
  35.  
  36.         //validating old password
  37.         $get_real_pass="select * from customers where customer_pass='$old_pass'";
  38.         $run_real_pass=mysqli_query($con,$get_real_pass);
  39.  
  40.         $check_pass=mysqli_num_rows($run_real_pass);
  41.  
  42.         if($check_pass==0)
  43.  
  44.         {
  45.             echo "<script> alert('Invalid current password!')</script>";
  46.             exit();
  47.         }
  48.         if($new_pass!=$new_pass_again)
  49.         {
  50.             echo "<script> alert('New password did not match!!')</script>";
  51.             exit();
  52.         }
  53.         else
  54.         {
  55.             $update_pass="update customers set customer_pass='$new_pass' WHERE customer_email='$current_user'";
  56.        
  57.             $run_pass=mysqli_query($con,$update_pass);
  58.  
  59.             if($run_pass)
  60.             {
  61.                 echo "<script> alert('Password changed successfully!')</script>";
  62.                 echo "<script>window.open('my_account.php','_self')</script>";
  63.             }
  64.             else
  65.             {
  66.                 echo "<script> alert('Error occured!!!')</script>";
  67.                 echo "<script>window.open('my_account.php','_self')</script>";
  68.             }
  69.         }
  70.     }
  71. ?>
Advertisement
Add Comment
Please, Sign In to add comment