summaryrefslogtreecommitdiff
path: root/signin.php
diff options
context:
space:
mode:
authorcflip <36554078+cflip@users.noreply.github.com>2021-06-23 15:21:12 -0600
committercflip <36554078+cflip@users.noreply.github.com>2021-06-23 15:21:12 -0600
commitf5e972c030675f46cda543e13da1b787457e070b (patch)
tree7c0d2bb4138fe60060ff73b61e15881765ba5412 /signin.php
parentfd0c3a283153d6f2d759e5e14888e40e65dc61b7 (diff)
Add the rest of the changes
Diffstat (limited to 'signin.php')
-rwxr-xr-x[-rw-r--r--]signin.php138
1 files changed, 69 insertions, 69 deletions
diff --git a/signin.php b/signin.php
index ef60750..195895a 100644..100755
--- a/signin.php
+++ b/signin.php
@@ -1,69 +1,69 @@
-<?php session_start() ?>
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <title>Sign in - cflip.net forum</title>
- <link rel="stylesheet" href="styles/style.css">
- </head>
- <body>
-<?php include_once './includes/templates/header.php' ?>
- <h2>Sign in</h2>
- <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
- <label for="user_name">Username: </label><br>
- <input type="text" name="user_name"><br>
- <label for="user_pass">Password: </label><br>
- <input type="password" name="user_pass"><br>
- <input type="submit" name="submit">
- </form>
-<?php
-include_once 'includes/error.php';
-
-function validate($data)
-{
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- return $data;
-}
-
-if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- $errors = array();
-
- if (empty($_POST['user_name'])) {
- $errors[] = 'Please provide a username.';
- } else {
- $user_name = validate($_POST['user_name']);
- }
-
- if (empty($_POST['user_pass'])) {
- $errors[] = 'Please provide a password.';
- } else {
- $user_pass = $_POST['user_pass'];
- }
-
- if (!empty($errors)) {
- $errstr = 'Please check the following problems: <ul>';
- foreach ($errors as $err) {
- $errstr .= '<li>' . $err . '</li>';
- }
- $errstr .= '</ul>';
- trigger_error($errstr);
- } else {
- $user = new User();
- $user->get_by_name($user_name);
-
- if (!$user->has_value()) {
- trigger_error('There is no user with that name. Did you mean to <a href="register.php">create a new account?</a>');
- } else {
- if (!password_verify($user_pass, $user->password)) {
- echo 'Password does not match!';
- } else {
- Session::get()->sign_in($user);
- header("Location: index.php");
- }
- }
- }
-}
-?>
- </body>
-</html>
+<?php session_start() ?>
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <title>Sign in - cflip.net forum</title>
+<?php include_once 'includes/templates/head.php'; ?>
+ </head>
+ <body>
+<?php include_once './includes/templates/header.php' ?>
+ <h2>Sign in</h2>
+ <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
+ <label for="user_name">Username: </label><br>
+ <input type="text" name="user_name"><br>
+ <label for="user_pass">Password: </label><br>
+ <input type="password" name="user_pass"><br>
+ <input type="submit" name="submit">
+ </form>
+<?php
+include_once 'includes/error.php';
+
+function validate($data)
+{
+ $data = trim($data);
+ $data = stripslashes($data);
+ $data = htmlspecialchars($data);
+ return $data;
+}
+
+if ($_SERVER['REQUEST_METHOD'] == 'POST') {
+ $errors = array();
+
+ if (empty($_POST['user_name'])) {
+ $errors[] = 'Please provide a username.';
+ } else {
+ $user_name = validate($_POST['user_name']);
+ }
+
+ if (empty($_POST['user_pass'])) {
+ $errors[] = 'Please provide a password.';
+ } else {
+ $user_pass = $_POST['user_pass'];
+ }
+
+ if (!empty($errors)) {
+ $errstr = 'Please check the following problems: <ul>';
+ foreach ($errors as $err) {
+ $errstr .= '<li>' . $err . '</li>';
+ }
+ $errstr .= '</ul>';
+ trigger_error($errstr);
+ } else {
+ $user = new User();
+ $user->get_by_name($user_name);
+
+ if (!$user->has_value()) {
+ trigger_error('There is no user with that name. Did you mean to <a href="register.php">create a new account?</a>');
+ } else {
+ if (!password_verify($user_pass, $user->password)) {
+ echo 'Password does not match!';
+ } else {
+ Session::get()->sign_in($user);
+ header("Location: index.php");
+ }
+ }
+ }
+}
+?>
+ </body>
+</html>