121 přidán editace zaka, assets formular zak
This commit is contained in:
parent
262afa0716
commit
803bc5ca63
14
www2databaze/assets/formular-zak.php
Normal file
14
www2databaze/assets/formular-zak.php
Normal file
@ -0,0 +1,14 @@
|
||||
<form method="POST">
|
||||
<input type="text" name="first_name" placeholder="Křestní jméno" required value="<?= htmlspecialchars($first_name )?>">
|
||||
<br>
|
||||
<input type="text" name="second_name" placeholder="Příjmení" value="<?= htmlspecialchars($second_name) ?>" required>
|
||||
<br>
|
||||
<input type="number" name="age" placeholder="Věk" min="10" value="<?= htmlspecialchars($age)?>" required>
|
||||
<br>
|
||||
<!-- text area pamatovátko vložit mezi tagy -->
|
||||
<textarea name="life" placeholder="Podrobnosti o žákovi" required><?= htmlspecialchars($life)?></textarea>
|
||||
<br>
|
||||
<input type="text" name="college" placeholder="Kolej" value="<?= htmlspecialchars($college) ?>" required>
|
||||
<br>
|
||||
<input type="submit" value="Uložit">
|
||||
</form>
|
45
www2databaze/editace-zaka.php
Normal file
45
www2databaze/editace-zaka.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
require "assets/database.php";
|
||||
require "assets/zak.php";
|
||||
|
||||
$connection = connectionDB();
|
||||
|
||||
if (isset($_GET["id"])){
|
||||
$one_student = getStudent($connection, $_GET["id"]);
|
||||
|
||||
// pokud se $one_student rovná true (jsou tam data) udělej co je v {} a pokud je false (nejsou data) vypíše chybu student nenaleze a umře proces
|
||||
if ($one_student) {
|
||||
// Zobrazí mi v políčkách formůláře data z databáze
|
||||
$first_name = $one_student["first_name"];
|
||||
$second_name = $one_student["second_name"];
|
||||
$age = $one_student["age"];
|
||||
$life = $one_student["life"];
|
||||
$college = $one_student["college"];
|
||||
} else {
|
||||
die("Student nenalezen");
|
||||
}
|
||||
|
||||
} else {
|
||||
// pokud není zadané ID vypiš (navazuje na první if)
|
||||
die("ID není zadáno, student nebyl nalezen");
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="cs">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php require "assets/header.php"?>
|
||||
|
||||
|
||||
<?php require "assets/formular-zak.php"; ?>
|
||||
|
||||
|
||||
<?php require "assets/footer.php"?>
|
||||
</body>
|
||||
</html>
|
@ -8,6 +8,9 @@ $connection = connectionDB();
|
||||
|
||||
if (isset($_GET["id"]) and is_numeric($_GET["id"])) {
|
||||
$students = getStudent($connection, $_GET["id"]);
|
||||
} else {
|
||||
// pokud není nastavené id nastav ho na null
|
||||
$one_student = null;
|
||||
}
|
||||
|
||||
|
||||
@ -38,6 +41,9 @@ if (isset($_GET["id"]) and is_numeric($_GET["id"])) {
|
||||
<p>Kolej: <?= htmlspecialchars($students["college"])?></p>
|
||||
<?php endif ?>
|
||||
</section>
|
||||
<section class="buttons">
|
||||
<a href="editace-zaka.php?id=<?= $students['id']?>">Editovat</a>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<?php require "assets/footer.php" ?>
|
||||
|
@ -81,20 +81,7 @@ if ($_SERVER ["REQUEST_METHOD"] === "POST") {
|
||||
|
||||
<main>
|
||||
<section class="add-form">
|
||||
<form action="pridat-zaka.php" method="POST">
|
||||
<input type="text" name="first_name" placeholder="Křestní jméno" required value="<?= htmlspecialchars($first_name )?>">
|
||||
<br>
|
||||
<input type="text" name="second_name" placeholder="Příjmení" value="<?= htmlspecialchars($second_name) ?>" required>
|
||||
<br>
|
||||
<input type="number" name="age" placeholder="Věk" min="10" value="<?= htmlspecialchars($age)?>" required>
|
||||
<br>
|
||||
<!-- text area pamatovátko vložit mezi tagy -->
|
||||
<textarea name="life" placeholder="Podrobnosti o žákovi" required><?= htmlspecialchars($life)?></textarea>
|
||||
<br>
|
||||
<input type="text" name="college" placeholder="Kolej" value="<?= htmlspecialchars($college) ?>" required>
|
||||
<br>
|
||||
<input type="submit" value="Přidat žáka">
|
||||
</form>
|
||||
<?php require "assets/formular-zak.php"; ?>
|
||||
|
||||
</section>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user