44 lines
1.4 KiB
PHP
44 lines
1.4 KiB
PHP
<?php
|
|
define("TITLE", "User Login");
|
|
include("template/header.php");
|
|
print("<h2>Login Form<h2>");
|
|
|
|
$formStart = "<form class='login' action='login.php' method='post'>";
|
|
$emailLabel = "<label for='email'>Email:</label>";
|
|
$emailInput = "<input type='email' name='email'>";
|
|
$passLabel = "<label for='pass'>Password:</label>";
|
|
$passInput = "<input type='password' name='pass'>";
|
|
$submit = "<input type='submit' name='submit' value='Log In'>";
|
|
$formEnd = "</form";
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|
$email = htmlspecialchars($_POST['email']);
|
|
$password = htmlspecialchars($_POST['pass']);
|
|
|
|
$stickyForm = $formStart .
|
|
$emailLabel . $emailInput .
|
|
$passLabel . $passInput .
|
|
$submit .
|
|
$formEnd;
|
|
|
|
if (!empty($email) && !empty($password)) {
|
|
if ((strtolower($email) == 'test@test.com') && ($password == 'test')) {
|
|
ob_end_clean();
|
|
header('Location: specials.php');
|
|
exit();
|
|
} else {
|
|
print("<p>Email or password is incorrect. Please try again.</p>" . $stickyForm);
|
|
}
|
|
} else {
|
|
print("<p>Email and password are required. Please try again.</p>" . $stickyForm);
|
|
}
|
|
} else {
|
|
print($stickyForm = $formStart .
|
|
$emailLabel . $emailInput .
|
|
$passLabel . $passInput .
|
|
$submit .
|
|
$formEnd);
|
|
}
|
|
|
|
include("template/footer.php");
|