From b6582662f09c19862dd0244588b51ffece44a86f Mon Sep 17 00:00:00 2001 From: Job Vonk Date: Mon, 9 Mar 2020 15:49:36 +0000 Subject: [PATCH] Did work on various big things. See CHANGELOG for more details. --- .gitignore | 1 + CHANGELOG | 5 ++++ README.md | 22 ++++++++++++++-- html/.htaccess | 0 html/css/index.css | 0 html/css/index.css.map | 0 html/css/index.scss | 0 html/index.php | 19 +++++++++++--- php/auth.php | 16 ++++++++++++ php/dashboard.php | 9 +++++++ php/index.php | 13 ++++++++++ php/login.php | 18 +++++++++++++ templates/dashboard.html.php | 2 ++ templates/index.html.php | 50 +++++++++++++++++++++++++++--------- templates/layout.html.php | 2 +- templates/login.html.php | 4 +-- 16 files changed, 140 insertions(+), 21 deletions(-) create mode 100755 .gitignore create mode 100755 CHANGELOG mode change 100644 => 100755 README.md mode change 100644 => 100755 html/.htaccess mode change 100644 => 100755 html/css/index.css mode change 100644 => 100755 html/css/index.css.map mode change 100644 => 100755 html/css/index.scss mode change 100644 => 100755 html/index.php create mode 100644 php/auth.php create mode 100755 php/dashboard.php create mode 100755 php/index.php create mode 100644 php/login.php create mode 100644 templates/dashboard.html.php mode change 100644 => 100755 templates/index.html.php mode change 100644 => 100755 templates/layout.html.php mode change 100644 => 100755 templates/login.html.php diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..00d3842 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +php/conn.php \ No newline at end of file diff --git a/CHANGELOG b/CHANGELOG new file mode 100755 index 0000000..ef4faf8 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,5 @@ +9 maart 2020: Verbinding met database gelegd. + Basis login systeem gemaakt. + README.md geüpdatet. + Routes gefixed. + Tabel gemaakt op de homepage voor het ophalen van de data in de rooster tabel. \ No newline at end of file diff --git a/README.md b/README.md old mode 100644 new mode 100755 index f3f5b67..dc45c0c --- a/README.md +++ b/README.md @@ -1,2 +1,20 @@ -## Gymrooster PHP -Rooster voor Het Heerenlanden waar leraren leerlingen kunnen laten weten waar de gymles wordt gegeven. \ No newline at end of file +## Gymrooster PHP edition 9000 +Rooster voor Het Heerenlanden waar leraren leerlingen kunnen laten weten waar de gymles wordt gegeven. + +Om het zelf te testen, gebruik de volgende commando's: +```bash +git clone https://gitea.arnweb.nl/Hecc-inc./gymrooster_php.git +cd gymrooster_php +``` + +Je hebt een apache2 web server nodig met php >= 7.3. Verder heb je ook een mariadb server nodig en php_mysqli. **Vul de details in in het bestand `php/conn.php` volgens https://www.w3schools.com/php/php_mysql_connect.asp.** + +In de mariadb database moet er een database zijn met twee tabellen 'rooster' en 'docenten'. De code voor een voorbeeld is: +```sql +CREATE DATABASE gymrooster; +USE gymrooster; +CREATE TABLE docenten (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, username TEXT NOT NULL, password TEXT NOT NULL, naam TEXT NOT NULL); +CREATE TABLE rooster (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, dag DATE NOT NULL, docent INT NOT NULL, opmerking TEXT NOT NULL, locatie INT NOT NULL); +INSERT INTO docenten (username, password, naam) VALUES ('test', 'test', 'test user'); +INSERT INTO rooster (dag, docent, opmerking, locatie) VALUES (DATE('2020-03-09'), 1, 'Dit is een opmerking', 2); +``` \ No newline at end of file diff --git a/html/.htaccess b/html/.htaccess old mode 100644 new mode 100755 diff --git a/html/css/index.css b/html/css/index.css old mode 100644 new mode 100755 diff --git a/html/css/index.css.map b/html/css/index.css.map old mode 100644 new mode 100755 diff --git a/html/css/index.scss b/html/css/index.scss old mode 100644 new mode 100755 diff --git a/html/index.php b/html/index.php old mode 100644 new mode 100755 index b8c2db4..45a2f8d --- a/html/index.php +++ b/html/index.php @@ -1,10 +1,21 @@ query("SELECT * FROM docenten WHERE username = '" . $_SESSION["username"] . "' AND password = '" . $_SESSION["password"] . "'"); + + if ($result->num_rows === 1) { + return true; + } else { + return false; + } +} diff --git a/php/dashboard.php b/php/dashboard.php new file mode 100755 index 0000000..6aa4466 --- /dev/null +++ b/php/dashboard.php @@ -0,0 +1,9 @@ +query("SELECT * FROM docenten WHERE username = '" . $_SESSION['username'] . "';"); + +$docent = $result->fetch_assoc(); diff --git a/php/index.php b/php/index.php new file mode 100755 index 0000000..f7b1baf --- /dev/null +++ b/php/index.php @@ -0,0 +1,13 @@ +query("SELECT * FROM rooster INNER JOIN docenten ON rooster.docent = docenten.id WHERE dag = DATE('" . $today . "');"); + +if ($result->num_rows === 1) { + $rooster = [$result->fetch_assoc()]; +} else { + $rooster = $result; +} \ No newline at end of file diff --git a/php/login.php b/php/login.php new file mode 100644 index 0000000..6253bf4 --- /dev/null +++ b/php/login.php @@ -0,0 +1,18 @@ +query("SELECT * FROM docenten WHERE username = '" . $_POST["username"] . "' AND password = '" . $_POST["password"] . "'"); + +if ($result->num_rows === 1) { + session_start(); + + $_SESSION["username"] = $_POST["username"]; + $_SESSION["password"] = $_POST["password"]; + + header('Location: /dashboard'); +} else { + echo 'Wrong password or username'; +} + + diff --git a/templates/dashboard.html.php b/templates/dashboard.html.php new file mode 100644 index 0000000..629780b --- /dev/null +++ b/templates/dashboard.html.php @@ -0,0 +1,2 @@ + +Welkom \ No newline at end of file diff --git a/templates/index.html.php b/templates/index.html.php old mode 100644 new mode 100755 index c0c5742..37c7611 --- a/templates/index.html.php +++ b/templates/index.html.php @@ -1,13 +1,39 @@ + + + + +
+ + + + + + + + + + + + + + + + + +
DocentLocatieOpmerkingen
+
\ No newline at end of file diff --git a/templates/layout.html.php b/templates/layout.html.php old mode 100644 new mode 100755 index d5093af..474d16c --- a/templates/layout.html.php +++ b/templates/layout.html.php @@ -9,7 +9,7 @@ diff --git a/templates/login.html.php b/templates/login.html.php old mode 100644 new mode 100755 index 1c809fc..fa5ef7d --- a/templates/login.html.php +++ b/templates/login.html.php @@ -1,11 +1,11 @@
-
+

Login




- +