<?php
session_start();
$plaintext_password = "";
$str_data = file_get_contents("api/vpn.json");
$data = json_decode($str_data, true); 
$json = $data['cred'];
$plaintext_password = $_POST['password'];  
  $hash = password_hash($plaintext_password, 
          PASSWORD_DEFAULT);

if (isset($_POST["submit"]))
	{
	$hash = $json["password"];
	
		$username=$json["username"];
	
		if(($_POST['username']==$username) && (password_verify($_POST['password'], $hash))) {
			session_regenerate_id();
			$_SESSION['loggedin'] = TRUE;
			$_SESSION['N'] = $_POST['username'];
			header('Location: dns.php');
		}else{
		echo "Wrong Username or Password Entered Try Again";
        }}?>
<!doctype html>
<html lang="en">
  <head>
  	<title>Devloper Panel</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

	<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700&display=swap" rel="stylesheet">

	<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
	
	<link rel="stylesheet" href="css/style.css">

	</head>
	<body class="img js-fullheight" style="background-image: url(img/background.jpg);">
	<section class="ftco-section">
		<div class="container">
			<div class="row justify-content-center">
				<div class="col-md-6 text-center mb-5">
					<h2 class="heading-section">Purle Devloper Panel</h2>
				</div>
			</div>
			<div class="row justify-content-center">
				<div class="col-md-6 col-lg-4">
					<div class="login-wrap p-0">
		      	<h3 class="mb-4 text-center">App ver10 Panel ver 1.0</h3>
		      	<form method="post">
		      		<div class="form-group">
		      			<input type="text" id="username" name="username" class="form-control" placeholder="Username" required>
		      		</div>
	            <div class="form-group">
	              <input id="password-field" type="password" id="password" name="password" class="form-control" placeholder="Password" required>
	              <span toggle="#password-field" class="fa fa-fw fa-eye field-icon toggle-password"></span>
	            </div>
	            <div class="form-group">
	            	<button type="submit" id="submit" name="submit"class="form-control btn btn-primary submit px-3">Sign In</button>
	            </div>
	            <div class="form-group d-md-flex">
	            	<div class="w-50">
		            	<label class="checkbox-wrap checkbox-primary">Remember Me
									  <input type="checkbox" checked>
									  <span class="checkmark"></span>
									</label>
								</div>
													</div>
	            </div>
	          </form>
	          
	          </div>
		      </div>
				</div>
			</div>
		</div>
	</section>

	<script src="js/jquery.min.js"></script>
  <script src="js/popper.js"></script>
  <script src="js/bootstrap.min.js"></script>
  <script src="js/main.js"></script>

	</body>
</html>
