Include bulma, make navbar, first edition user.php
This commit is contained in:
parent
c1b4875f4e
commit
621e3029d7
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
Binary file not shown.
After Width: | Height: | Size: 43 KiB |
Binary file not shown.
After Width: | Height: | Size: 176 KiB |
Binary file not shown.
After Width: | Height: | Size: 249 KiB |
Binary file not shown.
After Width: | Height: | Size: 237 KiB |
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,4 @@
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title><?php echo($title) ?></title>
|
||||||
|
<link rel="stylesheet" href="/css/bulma.min.css">
|
|
@ -0,0 +1,82 @@
|
||||||
|
<nav class="navbar mb-2" role="navigation" aria-label="main navigation">
|
||||||
|
<div class="navbar-brand">
|
||||||
|
<a class="navbar-item" href="https://bulma.io">
|
||||||
|
<img src="/assets/logo_black_thicc.png" class="m-0 image is-32x32">
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
|
||||||
|
<span aria-hidden="true"></span>
|
||||||
|
<span aria-hidden="true"></span>
|
||||||
|
<span aria-hidden="true"></span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="navbarBasicExample" class="navbar-menu">
|
||||||
|
<div class="navbar-start">
|
||||||
|
<a href="/" class="navbar-item">
|
||||||
|
Home
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a href="/me.php" class="navbar-item">
|
||||||
|
Your Profile
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<div class="navbar-item has-dropdown is-hoverable">
|
||||||
|
<a class="navbar-link">
|
||||||
|
Admin
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<div class="navbar-dropdown">
|
||||||
|
<a href="/user.php" class="navbar-item">
|
||||||
|
User Details
|
||||||
|
</a>
|
||||||
|
<a href="/paymentphp" class="navbar-item">
|
||||||
|
Payments
|
||||||
|
</a>
|
||||||
|
<a href="/quota.php" class="navbar-item">
|
||||||
|
Quota Management
|
||||||
|
</a>
|
||||||
|
<hr class="navbar-divider">
|
||||||
|
<a href="/adminer-4.8.1.php" class="navbar-item">
|
||||||
|
Adminer SQL
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="navbar-end">
|
||||||
|
<div class="navbar-item">
|
||||||
|
<div class="buttons">
|
||||||
|
<a href="/login.php" class="button is-link">
|
||||||
|
<?php
|
||||||
|
// TODO: Change this to a logout button if the user is logged in
|
||||||
|
?>
|
||||||
|
Log in
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<script>
|
||||||
|
// https://bulma.io/documentation/components/navbar/
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
// Get all "navbar-burger" elements
|
||||||
|
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
|
||||||
|
|
||||||
|
// Add a click event on each of them
|
||||||
|
$navbarBurgers.forEach( el => {
|
||||||
|
el.addEventListener('click', () => {
|
||||||
|
|
||||||
|
// Get the target from the "data-target" attribute
|
||||||
|
const target = el.dataset.target;
|
||||||
|
const $target = document.getElementById(target);
|
||||||
|
|
||||||
|
// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
|
||||||
|
el.classList.toggle('is-active');
|
||||||
|
$target.classList.toggle('is-active');
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -1,16 +1,20 @@
|
||||||
<?php
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" class="has-background-light">
|
||||||
include('./db_connect.php');
|
<head>
|
||||||
|
<?php
|
||||||
|
$title = "PVVMDB";
|
||||||
$res = pg_query($dbconn, "SELECT * FROM users");
|
include "includes/head.php";
|
||||||
if (!$res) {
|
?>
|
||||||
echo "An error occurred.\n";
|
</head>
|
||||||
exit;
|
<body >
|
||||||
}
|
<?php
|
||||||
|
include "includes/nav.php";
|
||||||
while ($row = pg_fetch_row($res)) {
|
?>
|
||||||
echo "id: $row[0] username: $row[1]";
|
<div class="container">
|
||||||
}
|
<h1 class="title">Welcome to PVVMDB</h1>
|
||||||
|
<p class="subtitle">
|
||||||
?>
|
This application is made to register and manage PVV Membership.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
|
@ -0,0 +1,136 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
include("db_connect.php");
|
||||||
|
|
||||||
|
if (isset($_GET['username'])) {
|
||||||
|
$query = pg_prepare($dbconn, "userid_by_username", 'SELECT id FROM users WHERE username = $1');
|
||||||
|
$result = pg_execute($dbconn, "userid_by_username", array($_GET['username']));
|
||||||
|
$row = pg_fetch_row($result);
|
||||||
|
$userid = $row[0];
|
||||||
|
|
||||||
|
if ($userid) {
|
||||||
|
header("Location: /user.php?id=$userid");
|
||||||
|
} else {
|
||||||
|
header("Location: /user.php?id=-1");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" class="has-background-light">
|
||||||
|
<head>
|
||||||
|
<?php
|
||||||
|
$title = "PVVMDB - User";
|
||||||
|
include "includes/head.php";
|
||||||
|
?>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<?php
|
||||||
|
include "includes/nav.php";
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="container box">
|
||||||
|
<?php
|
||||||
|
if (isset($_GET['id'])) {
|
||||||
|
$id = $_GET['id'];
|
||||||
|
|
||||||
|
$query = pg_prepare($dbconn, "user_by_id", 'SELECT * FROM users WHERE id = $1');
|
||||||
|
$query = pg_execute($dbconn, "user_by_id", array($id));
|
||||||
|
|
||||||
|
$user = pg_fetch_assoc($query);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php if (isset($_GET['id']) && $user != null): ?>
|
||||||
|
<div class="notification is-primary">
|
||||||
|
<h1 class="title">Show / edit <?php echo $user['username']; ?></h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form>
|
||||||
|
|
||||||
|
<label class="label">Username</label>
|
||||||
|
<input class="input" type="text" name="username" value="<?php echo $user['username']; ?>">
|
||||||
|
|
||||||
|
<label class="label">Name</label>
|
||||||
|
<input class="input" type="text" name="name" value="<?php echo $user['name']; ?>">
|
||||||
|
|
||||||
|
<label class="label">Email</label>
|
||||||
|
<input class="input" type="text" name="external_email" value="<?php echo $user['external_email']; ?>">
|
||||||
|
|
||||||
|
<label class="label">Phone</label>
|
||||||
|
<input class="input" type="text" name="phone" value="<?php echo $user['phone']; ?>">
|
||||||
|
|
||||||
|
<label class="label">Locked</label>
|
||||||
|
<input type="checkbox" name="locked" <?php if ($user['locked']=="t") echo "checked"; ?>>
|
||||||
|
|
||||||
|
<label class="label">Created at</label>
|
||||||
|
<input class="input" type="text" name="created_at" value="<?php echo $user['created_at']; ?>" disabled>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
<div class="columns">
|
||||||
|
<input class="button is-primary column m-2" type="submit" value="Save Changes" />
|
||||||
|
|
||||||
|
<!-- <a class="button is-danger column m-2" href="/user.php?id=<?php echo $user['id']; ?>&delete=true">Delete</a> -->
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<?php else: ?>
|
||||||
|
|
||||||
|
<?php if(isset($_GET['id'])): ?>
|
||||||
|
<div class="notification is-warning">
|
||||||
|
<h2 class="title">User not found</h2>
|
||||||
|
<p>The user you are looking for does not exist.</p>
|
||||||
|
<p>Please select a user from the list or enter a username.</p>
|
||||||
|
</div>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="notification is-info">
|
||||||
|
<h2 class="title">No user selected.</h2>
|
||||||
|
<p>Please select a user from the list or enter a username.</p>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<form method="GET" class="field has-addons my-4">
|
||||||
|
<div class="control is-expanded">
|
||||||
|
<input class="input" name="username" type="text" placeholder="Find a user">
|
||||||
|
</div>
|
||||||
|
<div class="control">
|
||||||
|
<a class="button is-link is-light">
|
||||||
|
Edit user
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<table class="table is-fullwidth">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Username</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Email</th>
|
||||||
|
<th>Edit</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
//TODO: Pagination
|
||||||
|
|
||||||
|
$query = "SELECT * FROM users";
|
||||||
|
$result = pg_query($dbconn, $query);
|
||||||
|
while ($row = pg_fetch_assoc($result)) {
|
||||||
|
echo "<tr>";
|
||||||
|
echo "<td><a href='user.php?id=" . $row['id'] . "'>" . $row['username'] . "</a></td>";
|
||||||
|
echo "<td>" . $row['name'] . "</td>";
|
||||||
|
echo "<td>" . $row['external_email'] . "</td>";
|
||||||
|
echo "<td><a class='button is-primary' href='user.php?id=" . $row['id'] . "'>Edit</a></td>";
|
||||||
|
echo "</tr>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue