-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscheduleManagement.php
More file actions
79 lines (75 loc) · 3.36 KB
/
Copy pathscheduleManagement.php
File metadata and controls
79 lines (75 loc) · 3.36 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
try{
include "dbconnect.php";
}catch(PDOException $e){
var_dump($e->getMessage());
echo "Database connexion error";
}
$bdd->query("SET NAMES 'utf8'");
if($_POST["add"]) {
$insert = "INSERT INTO `event` (`id`, `date_event`, `label`, `description`) VALUES (NULL, '" . $_POST["event-date"] . "', '" . $_POST["label"] . "', '" . $_POST["description"] . "');";
try{
$bdd->query($insert);
}catch(PDOException $e){
var_dump($e->getMessage());
}
header('Location: /scheduleManagement.php');
} else if($_POST["remove"]) {
$delete = "DELETE FROM `event` where `id` = " . $_POST["id"] . ";";
try{
$bdd->query($delete);
}catch(PDOException $e){
var_dump($e->getMessage());
}
header('Location: /scheduleManagement.php');
}
?>
<html>
<head>
<link rel="stylesheet" href="../css/normalize.css">
<link rel="stylesheet" href="../css/main.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<?php include "header.php"; ?>
<section>
<article>
<div class="wrapper">
<div class="logo">
<img src="img/calendar.png" alt="Logo" title="Logo"/>
</div>
<div class="content">
<div class='site-flex-item admin'>
<h1>create event</h1>
<form method="POST" class="form-event">
<div class="form-group">
<label for="label">Label</label>
<input type="text" id="label" class="form-control" name="label" placeholder="Event Label"/>
</div>
<div class="form-group">
<label for="description">Description</label>
<input type="text" id="description" class="form-control" name="description" placeholder="Event Description"/>
</div>
<div class="form-group">
<label for="event-date">Event Date</label>
<input id="event-date" name="event-date" class="form-control" type="date" value="<?php echo date('d') . "-" . date('m') . "-" . date('Y'); ?>">
</div>
<div>
<p>
<input class="btn btn-primary" type="submit" value="add" name="add">
</p>
</div>
</form>
</div>
<?php
$sql = 'SELECT e.id, e.date_event, e.description, e.label FROM `event` e order by date_event desc limit 100';
echo "<div class='site-flex-item admin'>";
foreach ($bdd->query($sql) as $row) {
echo "<div class='event-detail'>ID : " . $row['id'] . "  Date : " . $row['date_event'] . " " . "  Label : " . $row['label'] . "  Description : " . $row['description'] . "<form method='post'><input type='hidden' name='id' value='" . $row['id'] ."'/><input type='submit' class='btn btn-danger' name='remove' value='Remove'/></form></div>";
}?>
</div>
</div>
</article>
</section>
</body>
</html>