Editing: update_profile_client.php
Kembali
<?php include '../components/connect.php'; session_start(); $client_email = $_SESSION['client_email']; if(!isset($client_email)){ header('location:client_login.php'); } // echo($_SESSION['client_category']); if(isset($_POST['submit'])){ $name = $_POST['name']; $name = filter_var($name, FILTER_SANITIZE_STRING); $contact = $_POST['contact']; $contact = filter_var($contact, FILTER_SANITIZE_STRING); $update_profile_name = mysqli_query($conn,"UPDATE `client_login` SET client_name ='$name',client_contact='$contact' WHERE client_email = '$client_email' "); // $update_profile_name->execute([, $admin_id]); if($update_profile_name){ $empty_pass = 'da39a3ee5e6b4b0d3255bfef95601890afd80709'; $prev_pass = $_POST['prev_pass']; $old_pass = sha1($_POST['old_pass']); $old_pass = filter_var($old_pass, FILTER_SANITIZE_STRING); $new_pass = sha1($_POST['new_pass']); $new_pass = filter_var($new_pass, FILTER_SANITIZE_STRING); $confirm_pass = sha1($_POST['confirm_pass']); $confirm_pass = filter_var($confirm_pass, FILTER_SANITIZE_STRING); if($old_pass == $empty_pass){ $message[] = 'please enter old password!'; }elseif($old_pass != $prev_pass){ $message[] = 'old password not matched!'; }elseif($new_pass != $confirm_pass){ $message[] = 'confirm password not matched!'; }else{ if($new_pass != $empty_pass){ $update_client_pass = $conn->prepare("UPDATE `client_login` SET client_password = '$confirm_pass' WHERE client_email = '$client_email'"); // $update_client_pass->execute([$confirm_pass, $admin_id]); if($update_client_pass){ $message[] = 'password updated successfully!'; }else{ $message[] = 'please enter a new password!'; } } } } else{ $message[] = mysqli_error($conn); } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>update profile</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css"> <link rel="stylesheet" href="../css/admin_style.css"> </head> <body> <?php include '../components/client_header.php'; ?> <section class="form-container"> <form action="" method="post"> <h3>update profile</h3> <input type="hidden" name="prev_pass" value="<?= $fetch_profile['client_password']; ?>"> <input type="text" name="name" value="<?= $fetch_profile['client_name']; ?>" required placeholder="enter your username" maxlength="20" class="box" oninput="this.value = this.value.replace(/\s/g, '')"> <input type="text" name="contact" value="<?= $fetch_profile['client_contact']; ?>" required placeholder="enter your username" maxlength="20" class="box" oninput="this.value = this.value.replace(/\s/g, '')"> <input type="password" name="old_pass" placeholder="enter old password" maxlength="20" class="box" oninput="this.value = this.value.replace(/\s/g, '')"> <input type="password" name="new_pass" placeholder="enter new password" maxlength="20" class="box" oninput="this.value = this.value.replace(/\s/g, '')"> <input type="password" name="confirm_pass" placeholder="confirm new password" maxlength="20" class="box" oninput="this.value = this.value.replace(/\s/g, '')"> <input type="submit" value="update now" class="btn" name="submit"> </form> </section> <script src="../js/admin_script.js"></script> </body> </html>
SIMPAN PERUBAHAN