Files
mallardnet/views/login.php
2025-11-22 23:57:26 -08:00

77 lines
3.0 KiB
PHP

<?php
if (isset($_SESSION["user"]))
header("Location: /");
if (isset($_POST["login"])) {
$form = (object) [
"username" => htmlspecialchars($_POST["username"]),
"password" => htmlspecialchars($_POST["password"]),
];
$login = new Login($form->username, $form->password, $conn);
$login->checkUsername();
$login->checkPassword();
if ($login->error == NULL) {
$login->authUser();
header("Location: /");
}
}
?>
<html>
<head>
<title><?= $website->title; ?>: <?= $website->slogan; ?></title>
<link rel="stylesheet" href="styles/main.css">
</head>
<body>
<table class="container" align="center">
<tbody>
<?php require("includes/header.php"); ?>
<tr>
<td>
<table class="form-box big-box login" align="center" border="1">
<tbody>
<tr>
<th align="left" colspan="2">Duck login</th>
</tr>
<form action="/login" method="POST">
<tr>
<td class="label-box" align="right">username: </td>
<td><input type="text" name="username" /></td>
</tr>
<tr>
<td class="label-box" align="right">password: </td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td class="right-hidden-border"></td>
<td class="small-text">
<?php
if (isset($_POST["login"]) && isset($login))
if ($login->error != NULL) echo "<font style=\"color: #831f1f\">$login->error</font> <br>";
?>
Don't have an account? <a href="/apply">Apply here</a>.
</td>
</tr>
<tr class="top-hidden-border">
<td class="right-hidden-border"></td>
<td class="submit-pad"><input type="submit" name="login" value="login" /></td>
</tr>
</form>
</tbody>
</table>
</td>
</tr>
<?php require("includes/footer.php"); ?>
</tbody>
</table>
</body>
</html>