<?php session_start(); /* Starts the session */
	
	/* Check Login form submitted */	
	if(isset($_POST['Submit'])){
		/* Define username and associated password array */
		$logins = array(
			'admin' => 'meinADM17!'
		);
		
		/* Check and assign submitted Username and Password to new variable */
		$Username = isset($_POST['Username']) ? $_POST['Username'] : '';
		$Password = isset($_POST['Password']) ? $_POST['Password'] : '';
		
		/* Check Username and Password existence in defined array */		
		if (isset($logins[$Username]) && $logins[$Username] == $Password){
			/* Success: Set session variables and redirect to Protected page  */
			$_SESSION['UserData']['Username']=$logins[$Username];
			header("location:../index.php");
			exit;
		} 
		else {
			/*Unsuccessful attempt: Set error message */
			$msg="<div id='fail'>Benutzer oder Passwort falsch!</div>";
		}
	}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>LOGIN-FORM</title>
<link rel="icon" href="../assets/img/favicon.png">
<style>
*,*::after,*::before {margin:0;padding:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}
body {font-family:"open sans",arial,sans-serif;height:80vh}
#login-form {background:rgba(240,240,240,1);border:1px solid #ccc;border-radius:10px;text-align:center;margin:50px auto 0;padding:25px 35px;max-width:350px;position:relative;top:20%}
#login-form h1 {color:rgba(150,150,150,1);font-size:1.5em;text-transform:uppercase;letter-spacing:1px;margin:0 0 15px}
#login-form label,#login-form input {display:block;margin:10px 0 0;width:100%}
#login-form input {border:1px solid #ccc;border-radius:5px;padding:10px}
#login-form .send {background:rgba(139,0,0,1);border:0;color:rgba(255,255,255,1);cursor:pointer;text-transform:uppercase}
#login-form .send:hover {background:rgba(55,55,55,.9)}
#fail {background:rgba(139,0,0,.2);color:rgba(139,0,0,1);font-weight:700;text-align:center;margin:20px auto 0;padding:15px;max-width:350px}
.copy {display:inline-block;color:rgba(55,93,129,1);font-size:12px;text-decoration:none;outline:none;margin:15px 5px 0}</style>
</head>

<body>
<?php if(isset($msg)){echo $msg;}?>
<form id="login-form" action="" method="post">
	<h1>Anmeldung</h1>
	<label for="Username">Benutzername</label>
	<input name="Username" type="text" required>
	<label for="Password">Passwort</label>
	<input name="Password" type="password" required/>
	<input name="Submit" type="submit" class="send" value="Anmelden">
	<a class="copy" href="https://www.nucom.at" title="Nucom Media">&copy; Nucom Media</a>
</form>
</body>
</html>