-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave_element.php
More file actions
35 lines (28 loc) · 1.06 KB
/
save_element.php
File metadata and controls
35 lines (28 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
session_start();
require_once __DIR__ . '/includes/Auth.php';
require_once __DIR__ . '/includes/Database.php';
if (!isset($_SESSION['username'])) {
header('Location: login.php');
exit;
}
$pdo = Database::connect();
$id_geosite = $_POST['id_geosite'] ?? null;
$type = $_POST['type'] ?? '';
$scale = $_POST['scale'] ?? '';
$name = $_POST['name'] ?? '';
$description = $_POST['description'] ?? '';
$geometry = $_POST['geometry'] ?? null;
// If checkboxes are not specified,m then set them to 0
$abiotic = isset($_POST['abiotic']) ? 1 : 0;
$biotic = isset($_POST['biotic']) ? 1 : 0;
$cultural = isset($_POST['cultural']) ? 1 : 0;
if (!$id_geosite || !$type) {
die("No required data.");
}
// Add new element
$stmt = $pdo->prepare("INSERT INTO elements (fid, type, scale, name, description, abiotic, biotic, cultural, geojson) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->execute([$id_geosite, $type, $scale, $name, $description, $abiotic, $biotic, $cultural, $geometry]);
header("Location: geosite.php?fid=" . $id_geosite);
exit;
?>