<?php
#1.create map with the name users
#2 create username.txt
#3.add username and password in username.txt like this example:"username ~~ password"
# form with input's included
session_start();
if (isset($_GET['submit'])) {
$username = $_GET['username'];
$password = $_GET['password'];
$path = './users/'. $username . '.txt';
if (file_exists($path)) {
$userfile = file_get_contents($path);
$checker = explode('~~', $userfile);
if ($password == $checker[1]) {
$_SESSION['username'] = $username;
# script na succesfull login
} else { echo '<script type="text/javascript">alert("Password incorrect!")</script>';}
} else { echo '<script type="text/javascript">alert("Username incorrect!")</script>';}
} else #submit error
?>
<form class="login" action="login.php" method="get">
<h1>Login</h1>
<input type="firstname" name="username" value="" placeholder="Username..." required autofocus> <br />
<input type="password" name="password" value="" placeholder="Password..." required ><br />
<button type="submit" name="submit">Submit</button><br />
</form>