vytvoření .htaccess + úklid
This commit is contained in:
parent
5721707bda
commit
fbf69ffbc2
1
www2databaze/assets/.htaccess
Normal file
1
www2databaze/assets/.htaccess
Normal file
@ -0,0 +1 @@
|
||||
Require all denied
|
3
www2databaze/assets/header.php
Normal file
3
www2databaze/assets/header.php
Normal file
@ -0,0 +1,3 @@
|
||||
<header>
|
||||
<h1>Hlavička</h1>
|
||||
</header>
|
@ -3,26 +3,27 @@
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="cs">
|
||||
<head>
|
||||
<html lang="cs">
|
||||
<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>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
</head>
|
||||
<body>
|
||||
<?php require "assets/header.php" ?>
|
||||
|
||||
<main>
|
||||
<section class="main-heading">
|
||||
<h1>Škola čar a kouzel v Bradavicích</h1>
|
||||
</header>
|
||||
|
||||
|
||||
<main>
|
||||
</section>
|
||||
<section>
|
||||
<a href="zaci.php">Seznam všech žáků</a>
|
||||
</section>
|
||||
</main>
|
||||
</main>
|
||||
|
||||
|
||||
<footer></footer>
|
||||
</body>
|
||||
</html>
|
||||
<?php require "assets/footer.php" ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
global $connection;
|
||||
require "database.php";
|
||||
require "assets/database.php";
|
||||
|
||||
if (isset($_GET["id"]) and is_numeric($_GET["id"])) {
|
||||
$sql = "SELECT * FROM student WHERE id = ". $_GET["id"];
|
||||
@ -25,11 +25,12 @@ if (isset($_GET["id"]) and is_numeric($_GET["id"])) {
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Informace o žákovi</h1>
|
||||
</header>
|
||||
<?php require "assets/header.php" ?>
|
||||
|
||||
|
||||
|
||||
<main>
|
||||
<section class="main-heading"><h1>Informace o žákovi</h1></section>
|
||||
<section>
|
||||
<?php if ($students === null): ?>
|
||||
<p>Žák nenalezen</p>
|
||||
@ -37,13 +38,11 @@ if (isset($_GET["id"]) and is_numeric($_GET["id"])) {
|
||||
<h2><?php echo $students["first_name"]. " " .$students["second_name"] ?></h2>
|
||||
<p>Věk: <?php echo $students["age"] ?></p>
|
||||
<p>Dodatečné informace: <?= $students["life"] ?></p>
|
||||
<p>Kolej: <?= $students["collage"] ?></p>
|
||||
<p>Kolej: <?= $students["college"] ?></p>
|
||||
<?php endif ?>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
|
||||
</footer>
|
||||
<?php require "assets/footer.php" ?>
|
||||
</body>
|
||||
</html>
|
62
www2databaze/pridat-zaka.php
Normal file
62
www2databaze/pridat-zaka.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
|
||||
global $connection;
|
||||
if ($_SERVER ["REQUEST_METHOD"] === "POST") {
|
||||
|
||||
require "assets/database.php";
|
||||
|
||||
$sgl = "INSERT INTO student (first_name, second_name, age, life, college)
|
||||
VALUES ('" . $_POST["first_name"] . "','"
|
||||
. $_POST["second_name"] . "','"
|
||||
. $_POST["age"] . "','"
|
||||
. $_POST["life"] . "','"
|
||||
. $_POST["college"] . "')";
|
||||
// var_dump($sgl);
|
||||
// exit;
|
||||
$result = mysqli_query($connection, $sgl);
|
||||
|
||||
if ($result === false) {
|
||||
echo mysqli_error($connection);
|
||||
} else {
|
||||
$id = mysqli_insert_id($connection);
|
||||
echo "Úspěšně vložen žák s ID: $id";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="cs">
|
||||
<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>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php require "assets/header.php" ?>
|
||||
|
||||
<main>
|
||||
<section class="add-form">
|
||||
<form action="pridat-zaka.php" method="POST">
|
||||
<input type="text" name="first_name" placeholder="Křestní jméno">
|
||||
<br>
|
||||
<input type="text" name="second_name" placeholder="Příjmení">
|
||||
<br>
|
||||
<input type="number" name="age" placeholder="Věk" min="10">
|
||||
<br>
|
||||
<textarea name="life" placeholder="Podrobnosti o žákovi"></textarea>
|
||||
<br>
|
||||
<input type="text" name="college" placeholder="Kolej">
|
||||
<br>
|
||||
<input type="submit" value="Přidat žáka">
|
||||
</form>
|
||||
|
||||
</section>
|
||||
|
||||
</main>
|
||||
|
||||
|
||||
<?php require "assets/footer.php" ?>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
global $connection;
|
||||
require "database.php";
|
||||
require "assets/database.php";
|
||||
|
||||
$sql = "SELECT * FROM student";
|
||||
|
||||
@ -27,21 +27,28 @@ if ($result === false) {
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Seznam žáků školy</h1>
|
||||
<?php require "assets/header.php" ?>
|
||||
|
||||
<main>
|
||||
<section class="main-heading"><h1>Seznam žáků školy</h1></section>
|
||||
<section class="students-list">
|
||||
<?php
|
||||
if(empty($students)):
|
||||
?>
|
||||
<p>Žádní žáci nebyli nalezeni</p>
|
||||
|
||||
<?php else: ?>
|
||||
<ul>
|
||||
<?php foreach ($students as $one_student): ?>
|
||||
<li><?php echo $one_student["first_name"]. " " .$one_student["second_name"] ?></li>
|
||||
<li><?php echo $one_student["first_name"]. " " .$one_student["second_name"] ?></li>
|
||||
<a href="jeden-zak.php?id=<?= $one_student['id'] ?>">Více informací</a>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
<a href="index.php">Zpět na hlavní stranu</a>
|
||||
<?php endif; ?>
|
||||
<a href="index.php">Zpět na hlavní stranu</a>
|
||||
</section>
|
||||
</main>
|
||||
<?php require "assets/footer.php" ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user