From 6c9369ad85f2fb3dc61234b54db7e7079cdc0c4e Mon Sep 17 00:00:00 2001 From: cflip <36554078+cflip@users.noreply.github.com> Date: Fri, 23 Apr 2021 18:43:12 -0600 Subject: Refactoring part 1 --- signin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'signin.php') diff --git a/signin.php b/signin.php index e559614..cf41645 100644 --- a/signin.php +++ b/signin.php @@ -6,7 +6,7 @@ - +

Sign in

" method="post">
-- cgit v1.2.3 From 7c3f2e348c015ea93563d866f89ec8cea9159ea0 Mon Sep 17 00:00:00 2001 From: cflip <36554078+cflip@users.noreply.github.com> Date: Sat, 24 Apr 2021 09:40:20 -0600 Subject: Refactoring part 2 Starting to move some functionality such as the session and database connection into singleton classes to manage them. Functions for modifying posts and threads are being put in one place as well. --- signin.php | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'signin.php') diff --git a/signin.php b/signin.php index cf41645..9017d37 100644 --- a/signin.php +++ b/signin.php @@ -1,26 +1,27 @@ - + - + - Sign in - cflip.net forum - + Sign in - cflip.net forum + - -

Sign in

- " method="post"> -
-
-
-
- -
+ +

Sign in

+
" method="post"> +
+
+
+
+ +
Date: Sat, 24 Apr 2021 19:40:50 -0600 Subject: Remove all uses of db_inc.php This method of importing the database login every time wasn't very good. Now everything uses the new Database singleton class. --- signin.php | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) (limited to 'signin.php') diff --git a/signin.php b/signin.php index 9017d37..2c43309 100644 --- a/signin.php +++ b/signin.php @@ -18,8 +18,6 @@ '; } else { - $sql = "SELECT user_id, user_name, user_pass FROM users WHERE user_name = '" . $user_name . "';"; - $result = mysqli_query($dbc, $sql); + $user = new User(); + $result = $user->get_by_name($user_name); if (!$result) { - echo 'An error occurred while signing in: ' . mysqli_error($dbc); + echo 'There is no user with that name. Did you mean to create a new account?'; } else { - if (mysqli_num_rows($result) == 0) { - echo 'There is no user with that name. Did you mean to create a new account?'; + if (!password_verify($user_pass, $user->password)) { + echo 'Password does not match!'; } else { - while ($row = mysqli_fetch_assoc($result)) { - if (!password_verify($user_pass, $row['user_pass'])) { - echo 'Password does not match!'; - } else { - $_SESSION['signed_in'] = true; - $_SESSION['user_id'] = $row['user_id']; - $_SESSION['user_name'] = $row['user_name']; - - header("Location: index.php"); - } - } + Session::get()->sign_in($user); + header("Location: index.php"); } } } -- cgit v1.2.3