iwa-panda1

Manage Weather Data by International Weather Agency (Version 1)
Log | Files | Refs

commit 754782f0764349c261a583223531798e4abab412
parent f225280a835448e44899fe1cfca07d04d4eaed0f
Author: LennartSchroot <[email protected]>
Date:   Sun, 16 Apr 2023 15:00:10 +0200

joe

Diffstat:
Malteruser.php | 4++--
Mindex.php | 8++++++++
Mloginhandler.php | 2+-
Mnavbar.php | 4++--
Msearchdata.php | 6++++--
Msearchuser.php | 34++++++++++++++++++++++++++++++++--
Mtemplates/homepage.php | 5++---
7 files changed, 51 insertions(+), 12 deletions(-)

diff --git a/alteruser.php b/alteruser.php @@ -2,7 +2,7 @@ <html lang="nl"> <head> - <title>User toevoegen</title> + <title>User aanpassen</title> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"> </head> @@ -16,7 +16,7 @@ if (!in_array(1, $_SESSION['permissions'])) { <body> <div class="container"> - <h1>User toevoegen</h1> + <h1>User aanpassen</h1> <form action="crud_user.php" method="post"> <div class="mb-3"> diff --git a/index.php b/index.php @@ -29,6 +29,14 @@ $router->get('/login', function () { include 'templates/login.html'; }); +$router->get('/dashboard', function () { + include 'searchdata.php'; +}); + +//$router->get('/data', function () { +// include 'searchdata.php'; +//}); + $router->post('/login', function ($params) { }); diff --git a/loginhandler.php b/loginhandler.php @@ -22,7 +22,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { // create, prepare sql statement and execute sql statement $sql = "select u.email, u.password, p.permission_id, p.permission_name from user u - join user_permission up on up.email = u.email + join user_permission up on up.user_id = u.user_id join permission p on p.permission_id = up.permission_id where u.email = ? "; $stmt= $conn->prepare($sql); diff --git a/navbar.php b/navbar.php @@ -17,7 +17,7 @@ $admin_links = array( array('url' => '/crud_user.php', 'title' => 'Add User'), array('url' => '/searchuser.php', 'title' => 'Search for user'), - array('url' => '/alteruser', 'title' => 'Alter user') +// array('url' => '/alteruser', 'title' => 'Alter user') ); $links[] = array('name' => 'Admin', 'links' => $admin_links); } @@ -52,7 +52,7 @@ ?> <nav class="navbar navbar-expand-lg navbar-light bg-light"> - <a class="navbar-brand" href="#">Dashboard</a> + <a class="navbar-brand" href="/dashboard">Dashboard</a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> diff --git a/searchdata.php b/searchdata.php @@ -1,4 +1,6 @@ <?php +error_reporting(0); + include "navbar.php"; include "Connect.php"; ?> @@ -8,8 +10,8 @@ </head> <body> <form class="d-flex" action="searchdata.php" method="get"> - <input class="form-control me-2" type="date" name="date-begin" placeholder="Date begin" aria-label="Date begin"> - <input class="form-control me-2" type="date" name="date-end" placeholder="Date end" aria-label="Date end"> + <input class="form-control me-2" type="text" name="date-begin" placeholder="Date begin (YYYY-MM-DD)" pattern="\d{4}-\d{2}-\d{2}" required> + <input class="form-control me-2" type="text" name="date-end" placeholder="Date end (YYYY-MM-DD)" pattern="\d{4}-\d{2}-\d{2}" required> <input class="form-control me-2" type="text" name="station" placeholder="Search" aria-label="Search"> <button class="btn btn-outline-success" type="submit">Search</button> </form> diff --git a/searchuser.php b/searchuser.php @@ -14,8 +14,38 @@ <?php $connect = new Connect; $conn = $connect->getConn(); - - if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['search'])) { + + if (!isset($_POST['search'])){ + $sql = "SELECT email, first_name, last_name + FROM user"; + $stmt= $conn->prepare($sql); + $stmt->execute(); + + $result = $stmt->get_result(); + echo "<table class=\"table table-striped\"> + <thead> + <tr> + <th>E-mail</th> + <th>First name</th> + <th>Last name</th> + <th>Action</th> + </tr> + </thead> + <tbody>"; + while ($row = mysqli_fetch_assoc($result)) { + $link = "/alteruser.php?email=" . $row['email']; + echo "<tr>"; + echo "<td>" . $row['email'] . "</td>"; + echo "<td>" . $row['first_name'] . "</td>"; + echo "<td>" . $row['last_name'] . "</td>"; + echo "<td><a href='" . $link . "'>Edit</a></td>"; + echo "</tr>"; + } + echo" + </tbody> + </table>"; + } + if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['search'])) { $search = $_POST['search']; $search = "%" . $search . "%"; $sql = "SELECT u.email, u.first_name, u.last_name diff --git a/templates/homepage.php b/templates/homepage.php @@ -7,9 +7,8 @@ <body> <div class="header"> <h1>IWA - Weather Stations</h1> - <form class="search-form" action="/search"> - <input type="text" name="q" placeholder="Search for weather stations..."> - <button type="submit">Search</button> + <form class="search-form" action="/dashboard"> + <button type="submit">Search for weather stations</button> </form> </div>