-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodifier.php
More file actions
43 lines (39 loc) · 1.57 KB
/
Copy pathmodifier.php
File metadata and controls
43 lines (39 loc) · 1.57 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
<?php
require 'config.php';
$id = $_GET['id'] ?? null;
if($_SERVER['REQUEST_METHOD'] === "POST"){
$stmt = $pdo->prepare("UPDATE contacts SET nom=?, prenom=?, telephone=?, email=? WHERE id=?");
$stmt->execute([
$_POST['nom'],
$_POST['prenom'],
$_POST['telephone'],
$_POST['email'],
$_POST['id']
]);
header("Location: index.php");
}
$stmt = $pdo->prepare("SELECT * FROM contacts WHERE id=?");
$stmt->execute([$id]);
$contact = $stmt->fetch(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gestion contacts</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Modifier le contact</h1>
<form action="" method="POST">
<input type="hidden" name="id" value="<?= $contact['id'] ?>">
<label for="">Nom: <input type="text" name="nom" value="<?= htmlspecialchars($contact['nom']) ?>" required></label><br>
<label for="">Prenom: <input type="text" name="prenom" value="<?= htmlspecialchars($contact['prenom']) ?>" required></label><br>
<label for="">Telephone: <input type="text" name="telephone" value="<?= htmlspecialchars($contact['telephone']) ?>"></label><br>
<label for="">Email: <input type="email" name="email" value="<?= htmlspecialchars($contact['email']) ?>"></label><br>
<button type="submit">Mettre a jour</button>
</form>
<a href="index.php">Retour</a>
</body>
</html>