63 lines
1.6 KiB
PHP
63 lines
1.6 KiB
PHP
|
<?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>
|