-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcity.php
More file actions
49 lines (42 loc) · 1.5 KB
/
city.php
File metadata and controls
49 lines (42 loc) · 1.5 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
if(empty($_GET['id']) || !is_numeric($_GET['id'])) {
header('Location: /404.php');
exit;
}
require 'inc/pdo.php';
require 'inc/functions.php';
if(!empty($_POST['delete'])) {
$query = $pdo -> prepare('DELETE FROM city WHERE ID=:id');
$query -> bindValue(':id', $_GET['id'], PDO::PARAM_INT);
$deleted = $query -> execute();
$title = 'Ville supprimé !';
}else {
$query = $pdo -> prepare('SELECT * FROM city WHERE ID=:id');
$query -> bindValue(':id', $_GET['id'], PDO::PARAM_INT);
$query -> execute();
$city = $query->fetch();
if(!$city) {
header('Location: /404.php');
exit;
}
$title = $city['Name'];
}
include 'inc/header.php';
?>
<div class="container">
<?php if (isset($deleted) && $deleted) { ?>
<div class="success">
La ville a bien été supprimé ! <a href="/">Revenir sur la liste des villes</a>
</div>
<?php } else { ?>
<h1><?=$city['Name']?></h1>
<p><span>District</span>: <?=$city['District']?></p>
<p><span>Country Code</span>: <?=$city['CountryCode']?></p>
<p><span>Population</span>: <?=$city['Population']?></p>
<form action="/city.php?id=<?=$city['ID']?>" method="post">
<input type="submit" name="delete" value="Supprimer">
</form>
<?php } ?>
</div>
<?php
include 'inc/footer.php';