-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodifier.php
119 lines (79 loc) · 3.73 KB
/
modifier.php
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
form{
display: flex;
flex-direction:column;
background-color:beige;
border: 0px ;
border-radius:10px;
width:600px;
}
input, label{
width: 300px;
margin-left:150px;
}
</style>
</head>
<body style="display:flex;align-items:center;justify-content:center;">
<form action="" method="POST">
<h1 align="center">Hotels:</h1>
<!-- <label for="">Nom</label>
<input type="text" name="nom"><br> <br>
<label for="">Adresse</label>
<input type="text" name="adresse"><br> <br>
<label for="">Prix par nuit </label>
<input type="text" name="prix"><br> <br>
<label for="">Etoile </label>
<input type="number" name="etoile"><br> <br>
<label for="">Nombre de place </label>
<input type="text" name="place">
<input type="submit" value="ajouter" align="center" style="width:100px;height:30px;background-color:pink;border:0px;border-radius:15px;color:white;margin:30px;margin-left:250px"> -->
<?php
$host='localhost';
$dbname='hotels';
$username='root';
$passe='Farah@123';
$connexion= new PDO("mysql:host=$host; dbname=$dbname",$username, $passe);
$id= $_GET['id_hotel'];
$requet = $connexion ->query("select * from hotel where id_hotel=$id");
$data= $requet-> fetchAll(PDO::FETCH_ASSOC);
?>
<?php foreach ($data as $x):?>
<label for="">Nom</label>
<input type="text" name="nom" value="<?php echo $x['name']?>"><br> <br>
<label for="">Adresse</label>
<input type="text" name="adresse" value="<?php echo $x['adresse']?>"><br> <br>
<label for="">Prix par nuit </label>
<input type="text" name="prix" value="<?php echo $x['prix_par_nuit']?>"><br> <br>
<label for="">Etoile </label>
<input type="number" name="etoile" value="<?php echo $x['nbre_etoile']?>"><br> <br>
<label for="">Nombre de place </label>
<input type="text" name="place" value="<?php echo $x['nombre_de_place']?>">
<input type="submit" name="modifi" value="modifier" align="center" style="width:100px;height:30px;background-color:pink;border:0px;border-radius:15px;color:white;margin:30px;margin-left:250px">
<?php endforeach; ?>
<?php
if (isset($_POST['modifi'])) {
$Name=$_POST['nom'];
$Adresse=$_POST['adresse'];
$prix=$_POST['prix'];
$etoile=$_POST['etoile'];
$place=$_POST['place'];
// databaseconexxion
$host='localhost';
$dbname='hotels';
$username='root';
$passe='Farah@123';
$connexion= new PDO("mysql:host=$host; dbname=$dbname",$username, $passe);
$requet = $connexion ->prepare('update hotel set name=?,adresse=?,prix_par_nuit=?,nbre_etoile=?,nombre_de_place=? where id_hotel=?;');
$sup= $requet-> execute([$Name,$Adresse,$prix,$etoile,$place,$id]);
header('location: hotels.php');
}
?>
</form>
</body>
</html>