<?php session_start(); /* Starts the session */
	
	/* Check Login form submitted */	
	if(isset($_POST['Submit'])){
		/* Define username and associated password array */
		$logins = array(
			'Alex' => '123456',
			'username1' => 'password1',
			'username2' => 'password2'
		);
		
		/* 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>
<style>
*,*::after,*::before {margin:0;padding:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}
html,body {font-family:arial,sans-serif}
#login-form {background:rgba(240,240,240,1);margin:50px auto 0;padding:25px 25px;max-width:350px}
#login-form h1 {color:rgba(150,150,150,1);font-size:1.5em;text-transform:uppercase;margin:0 0 15px}
#login-form label,#login-form input {display:block;margin:10px 0 0;width:100%}
#login-form input {padding:10px}
#login-form input[type=submit] {background:rgba(143,173,38,1);color:rgba(255,255,255,1);border:0;cursor:pointer}
#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:flex;flex-direction:row-reverse;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" value="Anmelden">
	<a class="copy" href="https://www.nucom.at" title="Nucom Media">&copy; Nucom Media</a>
</form>
</body>
</html>