TablIP/addSite.php
2021-09-26 19:40:20 +02:00

17 lines
437 B
PHP

<?php
$siteName = filter_input(INPUT_POST, "siteName", FILTER_SANITIZE_STRING);
if (!$siteName) {
header("Location: 400.php");
exit;
}
include "connect.php";
try {
$insert = $db->prepare("INSERT INTO Sites(Name) VALUES(:name)");
$insert->execute(['name' => $siteName]);
$siteId = $db->lastInsertId();
header("Location: site.php?id=$siteId");
} catch(Exception $e) {
header("Location: 500.php");
exit;
}
?>