-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_element.php
More file actions
49 lines (40 loc) · 1.13 KB
/
update_element.php
File metadata and controls
49 lines (40 loc) · 1.13 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?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_element = $_POST['id_element'] ?? null;
$id_geosite = $_POST['id_geosite'] ?? null;
if (!$id_element || !$id_geosite) {
die("No required data.");
}
$type = $_POST['type'] ?? null;
$scale = $_POST['scale'] ?? null;
$name = $_POST['name'] ?? null;
$description = $_POST['description'] ?? null;
$geometry = $_POST['geometry'] ?? null;
// Checkboxes
$abiotic = isset($_POST['abiotic']) ? 1 : 0;
$biotic = isset($_POST['biotic']) ? 1 : 0;
$cultural = isset($_POST['cultural']) ? 1 : 0;
$stmt = $pdo->prepare("UPDATE elements
SET type = ?, scale = ?, name = ?, description = ?, geojson = ?, abiotic = ?, biotic = ?, cultural = ?
WHERE id_element = ?");
$stmt->execute([
$type,
$scale,
$name,
$description,
$geometry,
$abiotic,
$biotic,
$cultural,
$id_element
]);
header("Location: geosite.php?fid=" . $id_geosite);
exit;
?>