PHP lab 8

This commit is contained in:
2026-03-12 23:46:12 -04:00
parent 8b132e776f
commit 8c78e75b97
17 changed files with 273 additions and 1 deletions
+43
View File
@@ -0,0 +1,43 @@
<?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");