Browse Source

update nk

master
Jakub Škrabánek 2 years ago
parent
commit
db7a8df521
  1. 50
      nk_part5/admin.php
  2. 27
      nk_part5/list.php
  3. 10
      nk_part5/login.php
  4. 15
      nk_part5/reg.php
  5. 12
      nk_part5/write.php

50
nk_part5/admin.php

@ -26,17 +26,15 @@ if(isset($_SESSION["role"])){
<?php
include "menu.php";
?>
<hr>
<!-- PHP výpis pro příspěvky -->
<h2>Příspěvky</h2>
<table>
<table class="table">
<tr>
<th>id</th>
<th>title</th>
<th>msg</th>
<th>Autor</th>
<th>role autora</th>
<th>čas vytvoření</th>
<th>delete</th>
<th>update</th>
@ -51,15 +49,24 @@ if(isset($_SESSION["role"])){
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)){
echo "<tr>";
if ($row["role"] == "1"){
echo "<tr class=\"bg-primary-subtle\">";//admin
}
if ($row["role"] == "3"){
echo "<tr class=\"bg-success-subtle\">";//moderator
}
if ($row["role"] == "5"){
echo "<tr class=\"bg-warning-subtle\">";//ucet
}
echo "<td>".$row["id"]."</td>";
echo "<td>".$row["title"]."</td>";
echo "<td><strong>".$row["title"]."</strong></td>";
echo "<td>".$row["msg"]."</td>";
echo "<td><i>".$row["username"]."</i></td>";
//echo "<td>".$row["role"]."</td>"; //id=5">
echo "<td>".$row["created"]."</td>";
echo "<td>".$row["username"]."</td>";
echo "<td>".$row["role"]."</td>"; //id=5">
echo "<td> <a href=\"action_delete.php?id=".$row["id"]."\">Delete</a></td>";
echo "<td> <a href=\"update_prispevky.php?id=".$row["id"]."\">UPDATE</a></td>";
echo "<td> <a class=\"btn btn-danger\" href=\"action_delete.php?id=".$row["id"]."\">Delete</a></td>";
echo "<td> <a class=\"btn btn-warning\" href=\"update_prispevky.php?id=".$row["id"]."\">UPDATE</a></td>";
echo "</tr>";
}
}
@ -67,6 +74,12 @@ if(isset($_SESSION["role"])){
</table>
<h2>Users</h2>
<table class="table">
<tr>
<th>ID</th>
<th>Username</th>
<th>role</th>
</tr>
<?php
$sql = "SELECT * FROM nk_users";
@ -74,11 +87,26 @@ if(isset($_SESSION["role"])){
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)){
echo "<p>id:".$row["id"]."; user:".$row["username"]."</p>";
//echo "<p>id:".$row["id"]."; user:".$row["username"]."</p>";
if ($row["role"] == "1"){
echo "<tr class=\"bg-primary-subtle\">";//admin
}
if ($row["role"] == "3"){
echo "<tr class=\"bg-success-subtle\">";//moderator
}
if ($row["role"] == "5"){
echo "<tr class=\"bg-warning-subtle\">";//ucet
}
echo "<td>".$row["id"]."</td>";
echo "<td>".$row["username"]."</td>";
echo "<td>".$row["role"]."</td>";
echo "</tr>";
}
}
?>
</table>
</div>
<?php

27
nk_part5/list.php

@ -35,33 +35,44 @@ $ptitle= "Výpis knihy";
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)){
echo "<h2>".$row["title"] ."</h2>";
echo "<h4> od: " . $row["username"]."</h4>";
echo "<h5>". $row["created"] . "</h5>";
echo "<p>" . $row["msg"] . "</p>";
// puvodní formát:
// echo "<h4> od: " . $row["username"]."</h4>";
// echo "<h5>". $row["created"] . "</h5>";
// echo "<p>" . $row["msg"] . "</p>";
echo "<h2 class=\"display-3\">".$row["title"] ."</h2>";
echo "<figure>
<blockquote class=\"blockquote\">
<p>" . $row["msg"] . "</p>
</blockquote>
<figcaption class=\"blockquote-footer\">
". $row["username"] . " - <i>" . $row["created"]."</i>
</figcaption>
</figure>";
//kontrola přihlášenosti
if(isset($_SESSION["logged"])){
if ($_SESSION["role"] < 5) {
echo "<p> role vytvoření: ". $row["role"] . "</p>";
echo "<p class=\"lead\"> role vytvoření: ". $row["role"] . "</p>";
}
//pohled pro moderatora
if($_SESSION["role"] == 3 && $row["role"] == 5) {
echo "<a href=\"action_delete.php?id=".$row["id"]."\">Smazat příspěvek</a>";
echo "<a class=\"btn btn-outline-danger\" href=\"action_delete.php?id=".$row["id"]."\">Smazat příspěvek</a>";
}
//pohled nad vlasstní příspěvek
if( $row["username"] == $_SESSION["username"]){
echo "<a href=\"action_delete.php?id=".$row["id"]."\">Smazat příspěvek</a>";
echo "<a class=\"btn btn-outline-danger\" href=\"action_delete.php?id=".$row["id"]."\">Smazat příspěvek</a>";
}
//pohled pro admina
if($_SESSION["role"] == 1 && $row["username"] != $_SESSION["username"]) {
echo "<a href=\"action_delete.php?id=".$row["id"]."\">Smazat příspěvek</a>";
echo "<a class=\"btn btn-outline-danger\" href=\"action_delete.php?id=".$row["id"]."\">Smazat příspěvek</a>";
}

10
nk_part5/login.php

@ -18,15 +18,15 @@ $ptitle = "Login";
include "menu.php";
?>
<form action="action_login.php" method="post" class="form">
<label for="username">Uživatelské jméno</label>
<label for="username" class="form-label">Uživatelské jméno</label>
<br>
<input type="text" name="username" id="username">
<input type="text" name="username" id="username" class="form-control">
<br>
<label for="pw">Heslo</label>
<label for="pw" class="form-label">Heslo</label>
<br>
<input type="password" name="pw" id="pw">
<input type="password" name="pw" id="pw" class="form-control">
<br>
<input type="submit" value="Login">
<input type="submit" value="Login" class="btn btn-primary">
</form>
</div>

15
nk_part5/reg.php

@ -10,6 +10,7 @@ $ptitle = "Registrace";
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="css/bootstrap.css">
</head>
<body class="d-flex flex-column min-vh-100">
<div class="container">
@ -25,20 +26,20 @@ $ptitle = "Registrace";
}
?>
<form action="action_reg.php" method="post">
<label for="username">Přihlašovací jméno:</label><br>
<input type="text" name="username" id="username">
<label for="username" class="form-label">Přihlašovací jméno:</label><br>
<input type="text" name="username" id="username" class="form-control">
<br>
<label for="pw1">Heslo:</label><br>
<input type="password" name="pw1" id="pw1">
<label for="pw1" class="form-label">Heslo:</label><br>
<input type="password" name="pw1" id="pw1" class="form-control">
<br>
<label for="pw2">Opakovat heslo:</label><br>
<input type="password" name="pw2" id="pw2">
<label for="pw2" class="form-label">Opakovat heslo:</label><br>
<input type="password" name="pw2" id="pw2" class="form-control">
<br>
<br>
<input type="submit" value="Registrovat">
<input type="submit" value="Registrovat" class="btn btn-primary">
</form>
</div>

12
nk_part5/write.php

@ -22,14 +22,14 @@ $ptitle="Zápis do knihy";
<?php
include "menu.php";
?>
<form action="action_write.php" method="post">
<label for="title">Nadpis:</label><br>
<input type="text" name="title" id="title"><br>
<form action="action_write.php" method="post" >
<label for="title" class="form-label">Nadpis:</label><br>
<input type="text" name="title" id="title" class="form-control"><br>
<label for="msg">Zpráva do knihy:</label><br>
<textarea name="msg" id="msg" cols="30" rows="10"></textarea>
<label for="msg" class="form-label">Zpráva do knihy:</label><br>
<textarea name="msg" id="msg" cols="30" rows="10" class="form-control"></textarea>
<br>
<input type="submit" value="Zapsat do knihy">
<input type="submit" value="Zapsat do knihy" class="btn btn-primary">
</form>
</div>

Loading…
Cancel
Save