<?php session_start();
if(empty($_SESSION['id'])):
header('Location:../index.php');
endif;

include('../dist/includes/dbcon.php');

	$id = $_SESSION['id'];
	$password =$_POST['password'];
	$old =$_POST['passwordold'];
		$query=mysqli_query($con,"select void from user where user_id='$id'")or die(mysqli_error());
			$row=mysqli_fetch_array($query);
	
				$passold=$row['void'];
				
				if ($passold==$old)
				{
					if ($password<>"")
					{
						mysqli_query($con,"update user set void='$password' where user_id='$id'")or die(mysqli_error($con));
						mysqli_query($con,"update passcode set passcode='$password' where id='1'")or die(mysqli_error($con));
					}
					else
					{
						
					}
					
					$_SESSION['name']=$name;
					echo "<script type='text/javascript'>alert('Successfully updated Void details!');</script>";
					echo "<script>document.location='passcode.php'</script>";  
				}
				else
				{
					echo "<script type='text/javascript'>alert('Void mismatch!');</script>";
					echo "<script>document.location='passcode.php'</script>";  
				}
	
?>
