99 ochrana proti injecton útoku
This commit is contained in:
parent
0ab7f4a47f
commit
6f18eb5bfb
@ -2,25 +2,28 @@
|
|||||||
|
|
||||||
|
|
||||||
global $connection;
|
global $connection;
|
||||||
|
|
||||||
if ($_SERVER ["REQUEST_METHOD"] === "POST") {
|
if ($_SERVER ["REQUEST_METHOD"] === "POST") {
|
||||||
|
|
||||||
require "assets/database.php";
|
require "assets/database.php";
|
||||||
|
|
||||||
$sgl = "INSERT INTO student (first_name, second_name, age, life, college)
|
$sgl = "INSERT INTO student (first_name, second_name, age, life, college)
|
||||||
VALUES (?, ?, ?, ?, ?)";
|
VALUES (?, ?, ?, ?, ?)";
|
||||||
$statement = mysqli_prepare($connection, $sgl);
|
|
||||||
|
|
||||||
mysqli_stmt_bind_param($statement, "ssiss", $_POST["first_name"], $_POST["second_name"], $_POST["age"], $_POST["life"], $_POST["college"]);
|
$statement = mysqli_prepare($connection, $sgl);
|
||||||
mysqli_stmt_execute($statement);
|
|
||||||
|
|
||||||
// $result = mysqli_query($connection, $sgl);
|
if ($statement === false) {
|
||||||
//
|
echo mysqli_error($connection);
|
||||||
// if ($result === false) {
|
} else {
|
||||||
// echo mysqli_error($connection);
|
mysqli_stmt_bind_param($statement, "ssiss", $_POST["first_name"], $_POST["second_name"], $_POST["age"], $_POST["life"], $_POST["college"]);
|
||||||
// } else {
|
|
||||||
// $id = mysqli_insert_id($connection);
|
if (mysqli_stmt_execute($statement)) {
|
||||||
// echo "Úspěšně vložen žák s ID: $id";
|
$id = mysqli_insert_id($connection);
|
||||||
// }
|
echo "Úspěšně vložen žák s ID: $id";
|
||||||
|
} else {
|
||||||
|
echo mysgli_stmt_error($statement);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
Loading…
Reference in New Issue
Block a user