From 2980be21864cc183d9b4a3fad0417685265cbf0d Mon Sep 17 00:00:00 2001 From: Sam White Date: Sun, 24 Oct 2021 15:32:38 +0000 Subject: [PATCH] Add simple login system. --- public_html/includes/database.php | 6 ++++ public_html/includes/fields.php | 4 +++ public_html/login.php | 58 +++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 public_html/login.php diff --git a/public_html/includes/database.php b/public_html/includes/database.php index 4aa870f..e3a63d6 100644 --- a/public_html/includes/database.php +++ b/public_html/includes/database.php @@ -56,3 +56,9 @@ function insert_array($table, $fields) { . 'VALUES (' . implode(',', $values) . ')'; return run_sql($sql); } + +function fetch_record($table, $select, $where) { + $sql = "SELECT $select FROM $table WHERE $where"; + $result = run_sql($sql); + return mysqli_fetch_assoc($result); +} diff --git a/public_html/includes/fields.php b/public_html/includes/fields.php index 2419528..fe85168 100644 --- a/public_html/includes/fields.php +++ b/public_html/includes/fields.php @@ -43,6 +43,10 @@ function email_field($values, $name, $label, $attrs=[]) { general_field('email', $values, $name, $label, $attrs); } +function password_field($values, $name, $label, $attrs=[]) { + general_field('password', $values, $name, $label, $attrs); +} + function hidden_field($name, $value) { general_bare_field('hidden', [$name=>$value], $name); } diff --git a/public_html/login.php b/public_html/login.php new file mode 100644 index 0000000..022ddeb --- /dev/null +++ b/public_html/login.php @@ -0,0 +1,58 @@ + + +

Login

+ + + +
'']); + password_field($params, 'password', 'Password', ['required'=>'']);?> + +
-- 2.25.1