<?php
    require_once('session.php');
    if ($_POST['captcha_input'] != $_SESSION['captcha_code']) {
		header('location:../login?notif=5'); // Notifikasi 5: Captcha salah
		exit();
	}
    $pass = $u['pass'];
    $password = password_hash($_POST['pass'],PASSWORD_DEFAULT);
    $repass = mysqli_real_escape_string($conn,$_POST['repass']);
    $old_pass = mysqli_real_escape_string($conn,$_POST['old_pass']);

    if(password_verify($old_pass,$pass)){
        if(password_verify($repass,$password)){
            $stmt = $conn->prepare("UPDATE `tb_user` SET `pass` = ? WHERE cuid = ?");
            $stmt->bind_param("si", $pass, $userID);
            $stmt->execute();
            header('location:../account/password?notif=1');
            exit();
        }
        else {
            header('location:../account/password?notif=2');
            exit();
        }
    }
    else {
        header('location:../account/password?notif=3');
        exit();
    } 
    
?>