-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.php
More file actions
76 lines (69 loc) · 2.31 KB
/
delete.php
File metadata and controls
76 lines (69 loc) · 2.31 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
<?php
// confirmer
if(isset($_POST["id"]) && !empty($_POST["id"])){
// Inclure le fichier config
require_once "config.php";
// Prepare la requette
$sql = "DELETE FROM students WHERE id = ?";
if($stmt = mysqli_prepare($link, $sql)){
// Bind les variables
mysqli_stmt_bind_param($stmt, "i", $param_id);
// Set parameters
$param_id = trim($_POST["id"]);
// Executer
if(mysqli_stmt_execute($stmt)){
// supprimé, retourne
header("location: index.php");
exit();
} else{
echo "Oops! une erreur est survenue.";
}
}
// Close statement
mysqli_stmt_close($stmt);
// Close connection
mysqli_close($link);
} else{
// verifier si paramettre id exite
if(empty(trim($_GET["id"]))){
// pas de id, erreur
header("location: error.php");
exit();
}
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Supprimer l'enregistrement</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<style>
.wrapper{
width: 700px;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<h2 class="mt-5 mb-3">Supprimer l'enregistremnt</h2>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
<div class="alert alert-danger">
<input type="hidden" name="id" value="<?php echo trim($_GET["id"]); ?>"/>
<p>Etes vous sûr de vouloir supprimer cet étudiant ?</p>
<p>
<input type="submit" value="OUI" class="btn btn-danger">
<a href="index.php" class="btn btn-secondary">NON</a>
</p>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>