Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <h2 style="text-align:center;">Change your password</h2>
- <br>
- <br>
- <form action="" method="post">
- <table align="center" width="600" height="150">
- <tr>
- <td align="right"><b>Enter current password:</b></td>
- <td><input type="password" name="current_pass" required></td>
- </tr>
- <tr>
- <td align="right"><b>Enter new password:</b></td>
- <td><input type="password" name="new_pass" required></td>
- </tr>
- <tr>
- <td align="right"><b>Confirm your new password:</b></td>
- <td><input type="password" name="new_pass_again" required></td>
- </tr>
- <tr align="center">
- <td colspan="8"><input type="submit" name="change_pass" value="Change password"/></td>
- </tr>
- </table>
- </form>
- <?php
- include ("includes/db.php");
- if(isset($_POST['change_pass'])){
- $user = $_SESSION['customer_email'];
- $current_pass = $_POST['current_pass'];
- $new_pass = $_POST['new_pass'];
- $new_again = $_POST['new_pass_again'];
- $sel_pass = "select * from customers where customer_pass='$old_pass'
- AND customer_email='$user'";
- $run_pass = mysqli_query($con, $sel_pass);
- $check_pass = mysqli_num_rows($run_pass);
- if($check_pass==0){
- echo "<script>alert('Your current password is wrong!')</script>";
- exit();
- }
- if($new_pass!=$new_again){
- echo "<script>alert('ERROR! Insert new password again')</script>";
- exit();
- }
- else {
- $update_pass = "update customers set customer_pass='$new_pass'
- where customer_email='$user'";
- $run_update = mysqli_query($con, $update_pass);
- echo "<script>alert('Your password has been updated!')</script>";
- echo "<script>window.open('my_account.php','_self')</script>";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement