<?php
	session_start();

	$userID = $_SESSION['marry_userID'];
	$userPW = $_SESSION['marry_userPW'];
	$dbp = "userDB/";
	$filename = $dbp . $userID . ".txt";
	
	//read userfile
	$file = fopen($filename,"r");
		$readed = fread($file,filesize($filename));
		fclose($file);
	$rearray = explode("\r\n",$readed);
	
	if(password_verify($userPW, $rearray[0]) == false) {
		header("Location: wrong-pass.html");
	}
?>

<!DOCTYPE HTML>
	<head>
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>Change Password</title>
	</head>
	<body>
		<style>
			.gender {
				color: #24298f;
				background: #e0e2ff;
				padding: 5px;
				display: inline-block;
			}
		</style>
	
		<p><b>Mau Ganti Password?</b></p>
			<form method="POST" action="changepass.php">
				<label for="oldPW">Old Password: </label>
				<input type="password" name="oldPW" id="oldPW"><br>
					
				<label for="newPW">New Password: </label>
				<input type="password" name="newPW" id="newPW"><br>
					
				<label for="newPWC">Confirm New Password: </label>
				<input type="password" name="newPWC" id="newPWC"><br>
					
				<input type="submit" value="Change password">
			</form>
		<p>
			<b>Mau Ganti Gender?</b><br>
			<span class="gender">Gender anda sekarang: <b><?php echo $rearray[1]; ?></b></span>
		</p>
			<form method="POST" action="changegender.php">
				<label for="gender">New Gender: </label>
				<select id="gender" name="gender">
					<option value="male">Male</option>
					<option value="female">Female</option>
				</select><br>
					
				<input type="submit" value="Confirm Gender">
			</form><br>
		<button onclick="window.location.href='page.php'">Done or Cancel</button>
	</body>
</html>