4 changed files with 135 additions and 0 deletions
@ -0,0 +1,22 @@ |
|||||
|
<?php |
||||
|
session_start(); |
||||
|
require("init.php"); |
||||
|
$username = $_POST["username"]; |
||||
|
$pw = $_POST["pw"]; |
||||
|
|
||||
|
$sql = "SELECT * FROM nk_users |
||||
|
WHERE username='$username' AND password='$pw'"; |
||||
|
$result = mysqli_query($conn, $sql); |
||||
|
|
||||
|
if(mysqli_num_rows($result) == 1) { |
||||
|
$row = mysqli_fetch_assoc($result); |
||||
|
|
||||
|
$_SESSION["logged"] = 1; |
||||
|
$_SESSION["username"] = $row["username"]; |
||||
|
$_SESSION["role"] = $row["role"]; |
||||
|
|
||||
|
header("Location: /"); |
||||
|
} else { |
||||
|
header("Location: login.php?error=1"); |
||||
|
} |
||||
|
?> |
@ -0,0 +1,35 @@ |
|||||
|
<?php |
||||
|
session_start(); |
||||
|
include("init.php"); |
||||
|
|
||||
|
?> |
||||
|
<!DOCTYPE html> |
||||
|
<html lang="en"> |
||||
|
<head> |
||||
|
<meta charset="UTF-8"> |
||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||
|
<title>Navštěvní kniha</title> |
||||
|
</head> |
||||
|
<body> |
||||
|
<h1>Návštěvní kniha</h1> |
||||
|
|
||||
|
<ul> |
||||
|
<li><a href="/">HOME</a></li> |
||||
|
<li><a href="list.php">Vypsat knihu</a></li> |
||||
|
<li><a href="write.php">Zapsat do knihy</a></li> |
||||
|
<li><a href="reg.php">Registrovat se</a></li> |
||||
|
<li><a href="login.php">Přihlásit se</a></li> |
||||
|
</ul> |
||||
|
|
||||
|
<?php |
||||
|
if(isset($_SESSION["username"])){ |
||||
|
echo "<h2> vítej uživateli: ".$_SESSION["username"]."</h2>"; |
||||
|
} else { |
||||
|
echo "<h2> Prosím přihlaš se </h2>"; |
||||
|
} |
||||
|
|
||||
|
?> |
||||
|
|
||||
|
</body> |
||||
|
</html> |
@ -0,0 +1,49 @@ |
|||||
|
<?php |
||||
|
session_start(); |
||||
|
include("init.php"); |
||||
|
?> |
||||
|
<!DOCTYPE html> |
||||
|
<html lang="en"> |
||||
|
<head> |
||||
|
<meta charset="UTF-8"> |
||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||
|
<title>Výpis knihy</title> |
||||
|
</head> |
||||
|
<body> |
||||
|
<h1>Výpis knihy</h1> |
||||
|
|
||||
|
<ul> |
||||
|
<li><a href="/">HOME</a></li> |
||||
|
<li><a href="list.php">Vypsat knihu</a></li> |
||||
|
<li><a href="write.php">Zapsat do knihy</a></li> |
||||
|
<li><a href="reg.php">Registrovat se</a></li> |
||||
|
<li><a href="login.php">Přihlásit se</a></li> |
||||
|
</ul> |
||||
|
|
||||
|
<!-- <h2>Nadpis</h2> |
||||
|
<h4>od: jméno</h4> |
||||
|
<h5>cas</h5> |
||||
|
<p>zpráva</p> |
||||
|
<hr> --> |
||||
|
|
||||
|
<?php |
||||
|
$sql = "SELECT nk_prispevky.id, nk_users.username, nk_prispevky.title, nk_prispevky.msg, nk_prispevky.created |
||||
|
FROM nk_prispevky |
||||
|
INNER JOIN nk_users ON nk_prispevky.id_nk_users = nk_users.id |
||||
|
ORDER BY nk_prispevky.id"; |
||||
|
$result = mysqli_query($conn,$sql); |
||||
|
|
||||
|
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>"; |
||||
|
echo "<hr>"; |
||||
|
} |
||||
|
} |
||||
|
?> |
||||
|
|
||||
|
</body> |
||||
|
</html> |
@ -0,0 +1,29 @@ |
|||||
|
<?php |
||||
|
session_start(); |
||||
|
include("init.php"); |
||||
|
|
||||
|
?> |
||||
|
<!DOCTYPE html> |
||||
|
<html lang="en"> |
||||
|
<head> |
||||
|
<meta charset="UTF-8"> |
||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||
|
<title>Login</title> |
||||
|
</head> |
||||
|
<body> |
||||
|
<h1>Příhlášení</h1> |
||||
|
|
||||
|
<form action="action_login.php" method="post"> |
||||
|
<label for="username">Uživatelské jméno</label> |
||||
|
<br> |
||||
|
<input type="text" name="username" id="username"> |
||||
|
<br> |
||||
|
<label for="pw">Heslo</label> |
||||
|
<br> |
||||
|
<input type="password" name="pw" id="pw"> |
||||
|
<br> |
||||
|
<input type="submit" value="Login"> |
||||
|
</form> |
||||
|
</body> |
||||
|
</html> |
Loading…
Reference in new issue