-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod.php
324 lines (314 loc) · 16.8 KB
/
mod.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
<!DOCTYPE html>
<html>
<head>
<meta charset ="utf-8">
<title>Patients</title>
<link rel="stylesheet" href="style.css">
<meta name='viewport' content="width=device-width, initial-scale=1">
</head>
<body>
<?php
include('header.php');
if(!isset($_SESSION['Nom'])||!isset($_SESSION['Prenom'])){
echo '<meta http-equiv="refresh" content="0;url=index.php"/>';
}
if(isset($_GET['registre'])){
try{
include_once('db.php');
$req= $bd -> prepare('SELECT * FROM patient WHERE Registre = :Registre');
$req->execute(array('Registre'=>$_GET['registre']));
$donnees = $req->fetch();
}catch(Exception $e){
echo 'Erreur de chargement du patient '+$e;
}
}elseif(isset($_GET['matricule'])){
try{
include_once('db.php');
$req= $bd -> prepare('SELECT * FROM users WHERE Matricule = :Matricule');
$req->execute(array('Matricule'=>$_GET['matricule']));
$donnees = $req->fetch();
}catch(Exception $e){
echo 'Erreur de chargement du médecin '+$e;
}
}elseif(isset($_GET['ID'])){
try{
include_once('db.php');
$req= $bd -> prepare('SELECT * FROM consultation WHERE ID = :ID');
$req->execute(array('ID'=>$_GET['ID']));
$donnees = $req->fetch();
}catch(Exception $e){
echo 'Erreur de chargement de la séance '+$e;
}
}else{
echo '<meta http-equiv="refresh" content="0;url=index.php"/>';
}
$badNom=false;
$badPrenom=false;
$badSexe=false;
$badRue=false;
$badNumero=false;
$badCP=false;
$badVille=false;
$badPathologie=false;
$badBoite=false;
if(isset($_POST['nom']) && isset($_POST['prenom']) && isset($_POST['rue']) && isset($_POST['numero']) && isset($_POST['cp']) && isset($_POST['ville']) && isset($_POST['pathologie'])){
if(!preg_match("#^[A-Z][a-z]{1,49}$#", $_POST['nom'])){
$badNom=true;
}
if(!preg_match("#^[A-Z][a-zA-Z]{1,80}$#",$_POST['prenom'])){
$badPrenom=true;
}
if(!preg_match("#F|M#",$_POST['sexe'])){
$badSexe=true;
}
if(!preg_match("#[a-z]{1,100}$#",$_POST['rue'])){
$badRue=true;
}
if(!preg_match("#[0-9]{1,10}$#",$_POST['numero'])){
$badNumero=true;
}
if(!preg_match("#^[1-9][0-9]{1,3}$#",$_POST['cp'])){
$badCP=true;
}
if(!preg_match("#[a-z\-\ ]{1,50}$#",$_POST['ville'])){
$badVille=true;
}
if(!preg_match("#[A-Za-z\ ]#",$_POST['pathologie'])){
$badPathologie=true;
}
if(!preg_match("#[A-Z0-9]{0,10}#",$_POST['boite'])){
$badBoite=true;
}
if($badNom==false && $badPrenom==false && $badSexe==false && $badRue==false && $badNumero==false && $badCP==false && $badVille==false && $badPathologie==false && $badBoite==false){
try{
include_once('db.php');
$req= $bd->prepare('UPDATE patient SET Nom=:Nom, Prenom=:Prenom, Sexe=:Sexe, AdresseRue=:Rue, AdresseNumero=:Numero, AdresseBoite=:Boite, AdresseCodePostal=:CP, AdresseVille=:Ville, Pathologie=:Pathologie WHERE Registre=:RegistreToModify');
$req->execute(array('Nom' =>$_POST['nom'], 'Prenom' =>$_POST['prenom'], 'Sexe' =>$_POST['sexe'], 'Rue' =>$_POST['rue'], 'Numero' =>$_POST['numero'], 'Boite' =>$_POST['boite'], 'CP' =>$_POST['cp'], 'Ville' =>$_POST['ville'], 'Pathologie' =>$_POST['pathologie'], 'RegistreToModify' =>$_GET['registre']));
echo '<meta http-equiv="refresh" content="0;url=patient.php"/>';
}catch(Execption $e){
echo 'erreur de connection à la db'.$e;
}
}
}
$badMail=false;
$badService=false;
$badDroit=false;
$services=array(
"Urgence",
"Chirurgie ",
"Dermathologie",
"Gastroentérologie",
"Gynécologie",
"Neurologie",
"Psychiatrie",
"Radiologie",
"Soins intensifs ",
"Direction");
if(isset($_POST['nom']) && isset($_POST['prenom']) && isset($_POST['email']) && isset($_POST['service']) && isset($_POST['droit'])){
if(!preg_match("#^[A-Z][a-z]{1,49}$#", $_POST['nom'])){
$badNom=true;
}
if(!preg_match("#^[A-Z][a-zA-Z\ ]{1,80}$#",$_POST['prenom'])){
$badPrenom=true;
}
if(!preg_match("#^[0-9a-z\-\_\.]{1,}@[0-9a-z](\.?[0-9a-z])+\.?([a-z]){2,}$#",$_POST['email'])){
$badMail=true;
}
if(!in_array($_POST['service'],$services)){
$badService=true;
}
if(!preg_match("#[0-1]{1}$#",$_POST['droit'])){
$badDroit=true;
}
if(!$badNom && !$badPrenom && !$badMail && !$badService && !$badDroit){
try{
include_once('db.php');
$req= $bd->prepare('UPDATE users SET Nom=:Nom, Prenom=:Prenom, Email=:Email, Service=:Service, Droit=:Droit WHERE Matricule=:MatriculeToModify');
$req->execute(array('Nom' =>$_POST['nom'], 'Prenom' =>$_POST['prenom'], 'Email' =>$_POST['email'], 'Service' =>$_POST['service'], 'Droit' =>$_POST['droit'], 'MatriculeToModify' =>$_GET['matricule']));
echo 'check DB';
echo '<meta http-equiv="refresh" content="0;url=medecin.php"/>';
}catch(Exeption $e){
echo'erreur de connection à la db'+$e;
}
}
}
$badRegistre=false;
if(isset($_POST['date']) && isset($_POST['registre']) && isset($_POST['prescription']) && isset($_POST['note'])){
if(!preg_match("#[0-9]{9}$#",$_POST['registre'])){
$badRegistre=true;
}
strip_tags($_POST['prescription']);
strip_tags($_POST['note']);
if(!$badRegistre){
try{
include_once('db.php');
$req= $bd->prepare('UPDATE consultation SET RegistrePatient=:Registre, DateConsultation=:DateConsultation, Prescription=:Prescription, Notes=:Note WHERE ID=:IDToModify');
$req->execute(array('Registre' =>$_POST['registre'], 'DateConsultation' =>$_POST['date'], 'Prescription' =>$_POST['prescription'], 'Note' => $_POST['note'], 'IDToModify' =>$_GET['ID']));
echo 'go check db';
echo '<meta http-equiv="refresh" content="0;url=rdv.php"/>';
}catch(Exeption $e){
echo 'erreur de co a la db'.$e;
}
}
}
if(isset($_GET['registre'])){
?>
<main class="main">
<section class="section__right section--full">
<form class="info" method="POST" action='mod.php?registre=<?= $donnees["Registre"] ?>'>
<h2 class="info__title">N° de registre national : </h2>
<input class="info__input" name="registre" value="<?= $donnees['Registre'] ?>" disabled="disabled">
<h2 class="info__title">Nom : </h2>
<input class="info__input" name="nom" value="<?php if(isset($_POST['nom'])){echo $_POST['nom'];}else{echo $donnees['Nom'];} ?>">
<?php
if($badNom){
echo '<label class="red"> Nom invalide </label>';
}
?>
<h2 class="info__title">Prenom : </h2>
<input class="info__input" name="prenom" value="<?php if(isset($_POST['prenom'])){echo $_POST['prenom'];}else{echo $donnees['Prenom'];} ?>">
<?php
if($badPrenom){
echo '<label class="red"> Prenom invalide </label>';
}
?>
<h2 class="info__title">Sexe : </h2>
<input class="info__input" name="sexe" value="<?php if(isset($_POST['sexe'])){echo $_POST['sexe'];}else{echo $donnees['Sexe'];} ?>">
<?php
if($badSexe){
echo '<label class="red"> Sexe invalide </label>';
}
?>
<h2 class="info__title">Rue : </h2>
<input class="info__input" name="rue" value="<?php if(isset($_POST['rue'])){echo $_POST['rue'];}else{echo $donnees['AdresseRue'];} ?>">
<?php
if($badRue){
echo '<label class="red"> Rue invalide </label>';
}
?>
<h2 class="info__title">Numéro : </h2>
<input class="info__input" name="numero" value="<?php if(isset($_POST['numero'])){echo $_POST['numero'];}else{echo $donnees['AdresseNumero'];} ?>">
<?php
if($badNumero){
echo '<label class="red"> Numero invalide </label>';
}
?>
<h2 class="info__title">Boite : </h2>
<input class="info__input" name="boite" value="<?php if(isset($_POST['boite'])){echo $_POST['boite'];}else{echo $donnees['AdresseBoite'];} ?>">
<?php
if($badBoite){
echo '<label class="red"> Boite invalide </label>';
}
?>
<h2 class="info__title">Code Postal : </h2>
<input class="info__input" name="cp" value="<?php if(isset($_POST['cp'])){echo $_POST['cp'];}else{echo $donnees['AdresseCodePostal'];} ?>">
<?php
if($badCP){
echo '<label class="red"> Code postal invalide </label>';
}
?>
<h2 class="info__title">Ville : </h2>
<input class="info__input" name="ville" value="<?php if(isset($_POST['ville'])){echo $_POST['ville'];}else{echo $donnees['AdresseVille'];} ?>">
<?php
if($badVille){
echo '<label class="red"> Ville invalide </label>';
}
?>
<h2 class="info__title">Pathologie : </h2>
<input class="info__input" name="pathologie" value="<?php if(isset($_POST['pathologie'])){echo $_POST['pathologie'];}else{echo $donnees['Pathologie'];} ?>">
<?php
if($badPathologie){
echo '<label class="red"> Pathologie invalide </label>';
}
?>
<div class="button__container">
<a href="patient.php" class="info__cancel">Annuler</a>
<button type="submit" class="info__submit">Confirmer</button>
</div>
</form>
</section>
</main>
<?php
}elseif(isset($_GET['matricule'])){
?>
<main class="main">
<section class="section__right section--full">
<form class="info" method="POST" action='mod.php?matricule=<?= $donnees["Matricule"] ?>'>
<h2 class="info__title">Matricule : </h2>
<input class="info__input" name="matricule" value="<?= $donnees['Matricule'] ?>" disabled="disabled">
<h2 class="info__title">Nom : </h2>
<input class="info__input" name="nom" value="<?php if(isset($_POST['nom'])){echo $_POST['nom'];}else{echo $donnees['Nom'];} ?>">
<?php
if($badNom){
echo '<label class="red"> Nom invalide </label>';
}
?>
<h2 class="info__title">Prenom : </h2>
<input class="info__input" name="prenom" value="<?php if(isset($_POST['prenom'])){echo $_POST['prenom'];}else{echo $donnees['Prenom'];} ?>">
<?php
if($badPrenom){
echo '<label class="red"> Prenom invalide </label>';
}
?>
<h2 class="info__title">Email : </h2>
<input class="info__input" name="email" value="<?php if(isset($_POST['email'])){echo $_POST['email'];}else{echo $donnees['Email'];} ?>">
<?php
if($badMail){
echo '<label class="red"> Mail invalide </label>';
}
?>
<h2 class="info__title">Service : </h2>
<input class="info__input" name="service" value="<?php if(isset($_POST['service'])){echo $_POST['service'];}else{echo $donnees['Service'];} ?>">
<?php
if($badService){
echo '<label class="red"> Service invalide </label>';
}
?>
<h2 class="info__title">Droit : </h2>
<input class="info__input" name="droit" value="<?php if(isset($_POST['droit'])){echo $_POST['droit'];}else{echo $donnees['Droit'];} ?>">
<?php
if($badDroit){
echo '<label class="red"> Droit invalide </label>';
}
?>
<div class="button__container">
<a href="medecin.php" class="info__cancel">Annuler</a>
<button type="submit" class="info__submit">Confirmer</button>
</div>
</form>
</section>
</main>
<?php
}elseif(isset($_GET['ID'])){
?>
<main class="main">
<section class="section__right section--full">
<form class="info" method="POST" action='mod.php?ID=<?= $donnees["ID"] ?>'>
<h2 class="info__title">Date : </h2>
<input class="info__input" name="date" type="date" value="<?php if(isset($_POST['date'])){echo $_POST['date'];}else{echo $donnees['DateConsultation'];} ?>">
<h2 class="info__title">Registre : </h2>
<input class="info__input" name="registre" value="<?php if(isset($_POST['registre'])){echo $_POST['registre'];}else{echo $donnees['RegistrePatient'];} ?>">
<?php
if($badRegistre){
echo '<label class="red"> Nom invalide </label>';
}
?>
<h2 class="info__title">Prescription : </h2>
<textarea class="info__textBox" name="prescription"><?php if(isset($_POST['prescription'])){echo $_POST['prescription'];}else{echo $donnees['Prescription'];} ?></textarea>
<h2 class="info__title">Notes : </h2>
<textarea class="info__textBox" name="note"><?php if(isset($_POST['note'])){echo $_POST['note'];}else{echo $donnees['Notes'];} ?></textarea>
<div class="button__container">
<a href="rdv.php" class="info__cancel">Annuler</a>
<button type="submit" class="info__submit">Confirmer</button>
</div>
</form>
</section>
</main>
<?php } ?>
<footer class="footer">
<p> © 2016-2017 HEH ISFTR - développement </p>
<p> Florian Simond </p>
<p> Projet scolaire dans le cadre du cours de PHP </p>
</footer>
</body>
</html>