<?php 

session_start();
if(!isset($_SESSION["login"]) ) {
	header("Location: login.php");
	exit;
}	





require 'functions.php';


if( isset($_POST["gantipassz"]) ) {
	if( gantipass($_POST) > 0 ) {
		echo "<script>
				alert('Password berhasil diubah !');
				document.location.href = 'index.php';
			  </script>";
	} else {
		echo "<script>
				alert('Password gagal diubah !');
				document.location.href = 'gantipass.php';
			  </script>";
	}
}


//if( isset($_POST["gantipassz"]) ) {

//	if( gantipass($_POST) > 0 ) {
//		echo "<script>
//				alert('Password baru berhasil diubah!');
//			  </script>";
//	} else {
//		echo mysqli_error($conn);
//	}
//}

?>
<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
<link rel="shortcut icon" href="idea.png">    
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

	<title>Ganti Password</title>
	<style>
		label {
			display: block;
		}
	</style>
</head>
<body>

<a href="logout.php"> |Logout|</a>
<a href="index.php"> Home|</a>

<h1>Ganti Password</h1>

	<table>
	<form action="" method="post">
		
				
    	<tr>
			<td><label for="username">Username :</label></td>
			<td><input type="text" name="username" id="username" onkeyup="this.value = this.value.toUpperCase()" autofocus></td>
		</tr>
		
		<tr>
			<td><label for="passwordold">Password Lama : </label></td>
			<td><input type="password" name="passwordold" id="passwordold" onkeyup="this.value = this.value.toUpperCase()"></td>
		</tr>
		<tr>
		
		<tr>
			<td><label for="password">Password Baru : </label></td>
			<td><input type="password" name="password" id="password" onkeyup="this.value = this.value.toUpperCase()"></td>
		</tr>
		<tr>
			<td><label for="password2">Konfirmasi Password : </label></td>
			<td><input type="password" name="password2" id="password2" onkeyup="this.value = this.value.toUpperCase()"></td>
		</tr>
		
		
			<td colspan="2">

                <button type="submit" class="btn btn-danger" name="gantipassz">Ganti Password!</button>

				
</td>

</form>
</body>
</html>