<?php
include('database.php');
session_start();
$id= $_SESSION['id'];

if(isset($_POST['submit']))
{
	$pina = mysqli_real_escape_string($connection,  $_POST['pina']);
	$pinb = mysqli_real_escape_string($connection,  $_POST['pinb']);
	$pinc = mysqli_real_escape_string($connection,  $_POST['pinc']);
	$pind = mysqli_real_escape_string($connection,  $_POST['pind']);
	
	

    $query ="UPDATE users SET pina='$pina', pinb='$pinb', pinc='$pinc', pind='$pind' WHERE id='$id'";
    $query_run = mysqli_query($connection, $query);
    if($query_run)
    {
		$_SESSION['status'] = "<h5 style='padding:8px; background: #000; border-radius: 10px; color: #fff; text-align: center;'>PIN UPDATED SUCCESSFULLY</h5>";
		header('location:../index.php');
	}
    else
    {
		$_SESSION['status'] = "error.. pin not updated";
		header('location:../enter-code.php');
	}		
}else {
	$_SESSION['status'] = "<h5 style='padding:8px; background: #fe8b8e; border-radius: 10px; color: #fff; text-align: center;'>INCORRECT CURRENT PASSWORD</h5>";
	header('location:../enter-code.php');	
}


?>