-
Notifications
You must be signed in to change notification settings - Fork 0
/
tennis.php
243 lines (186 loc) · 9.2 KB
/
tennis.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
<?php
/**
* @file tennis.php.
* @author Leon Zhang .
* @version 1.0.
* @date 30 janvier 2019.
* @brief Page @b Tennis du site.
* @details Cette page comporte un module d'@b authentification
* permettant au membre, moniteur ou à l'administrateur
* de se connecter si celui-ci possède un compte. Le module
* comporte aussi un lien renvoyant vers une page d'@b inscription pour
* le visiteur non inscrit.
*/
require_once("inc/connectDB.php"); /** Connexion à la base de données.*/
require_once("inc/sessionUtilisateur.php"); /** Start session.*/
require_once("inc/fonctionsFichiers.php"); /** Fichiers contenant les fonctions.*/
define ("CATEGORIE", "tennis");
$listeActivites = listeActivites($conn, CATEGORIE);
$identifiant="";
$mot_de_passe="";
$erreur=true;
$fonction=""; /** Permet de sélectionner via le select la requête MySql adéquate.*/
if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['fonction']))
{
$identifiant = trim($_POST['username']); /** Retirer les espaces vides avant et après le mot saisi.*/
$mot_de_passe = trim($_POST['password']); /** Retirer les espaces vides avant et après le mot saisi.*/
$fonction= $_POST['fonction'];
if (!preg_match('/[^@]+@[^\.]+\..+$/', $identifiant))
{
$erreur = false;
echo "No"; /** À la valeur NO correspond un message d'erreur.*/
}
if (!preg_match('/^[A-Za-z]{1,8}\d$/', $mot_de_passe))
{
$erreur = false;
echo "No"; /** À la valeur NO correspond un message d'erreur.*/
}
if($erreur==true)
{
if($fonction==1) /** 1 correspond au membre.*/
{
if (AuthentificationUtilisateur($conn, $identifiant, $mot_de_passe) === 1)
{
$_SESSION['categorie'] = "musculation";
$infoMembre = lireUtilisateur($conn, $identifiant);
$_SESSION['nom'] = $infoMembre[0]['nom_utilisateur'];
$_SESSION['prenom'] = $infoMembre[0]['prenom_utilisateur'];
$_SESSION['id_utilisateur'] = $infoMembre[0]['id_utilisateur'];
$_SESSION['identifiant_utilisateur'] = $identifiant;
$_SESSION['categorie'] = CATEGORIE;
echo "01"; /** 01 correspond au membre.*/
}
else
{
echo "No"; /** À la valeur NO correspond un message d'erreur.*/
}
}
if($fonction==2) /** 2 correspond à l'animateur.*/
{
if(AuthentificationGestionnaire($conn, $identifiant, $mot_de_passe, $fonction) === 1)
{
$infoAnimateur = lireGestionnaire($conn, $identifiant);
$_SESSION['nom'] = $infoAnimateur[0]['nom'];
$_SESSION['prenom'] = $infoAnimateur[0]['prenom'];
$_SESSION['id_utilisateur'] = $infoAnimateur[0]['idgestions'];
$_SESSION['identifiant_teacher'] = $identifiant;
$identifiant="";
$mot_de_passe="";
echo "02"; /** 02 correspond au moniteur.*/
}
else
{
echo "No"; /** À la valeur NO correspond un message d'erreur.*/
}
}
if($fonction==3) /** 3 correspond à l'animateur.*/
{
if(AuthentificationGestionnaire($conn, $identifiant, $mot_de_passe, $fonction) === 1)
{
$_SESSION['identifiant_admin'] = $identifiant;
$identifiant="";
$mot_de_passe="";
echo "03"; /** 03 correspond à l'administrateur.*/
}
else
{
echo "No"; /** À la valeur NO correspond un message d'erreur.*/
}
}
}
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<?php require_once("head.php");?> <!-- head -->
<title>Tennis</title>
</head>
<body>
<header>
<?php require_once("header.php");?> <!-- header -->
</header>
<div class="modal fade " id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content border-0 rounded-0">
<div class="modal-header rounded-0">
<h5 class="modal-title" id="exampleModalCenterTitle">Se connecter</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span class="croix" id="croix" aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<!-- error message field -->
<div id="message-erreur" class="message-erreur">
<p id="erreurbis2"></p>
</div> <!-- end error message field -->
<form class="formulaireindex">
<div class="form-group">
<label for="exampleInputEmail1">Courriel</label>
<input type="email" name="username" id="username" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="john2@exemple.com" required>
<small id="emailHelp" class="form-text text-muted">Nous garantissons la confidentialité de votre courriel.</small>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Mot de passe</label>
<input type="text" name="password" id="password" class="form-control" id="exampleInputPassword1" placeholder="8 lettres max. suivi d'un chiffre max." required>
</div>
<div class="form-group">
<label for="exampleInputSelect1">Identifiez-vous</label>
<select name="fonction" id="fonction" class="custom-select" id="exampleInputSelect1">
<option value="1">Membre du club</option>
<option value="2">Moniteur de sport</option>
<option value="3">Administrateur du site</option>
</select>
</div>
<div class="centrer-bouton">
<button type="button" name="envoi" id="envoyer" class="btn btn-sm text-white">Envoyer</button>
</div>
</form> <!-- end form -->
</div> <!-- end modal body -->
<div class="modal-footer text-white">
<a class="text-white" id="bouton-onglet" href="inscription.php"><i class="fas fa-user-alt mr-2"></i>S'inscrire</a>
</div> <!-- end footer modal -->
</div> <!-- end modal content -->
</div> <!-- end modal wrapper -->
</div> <!-- end modal main container -->
<div class="container-activites biopic img-fluid">
<img class="tennis img-fluid" src="./images/tennis_teacher.jpg" class="tennis img-fluid">
<div class="text-bio">
<h3 class="nom">Raphael</h3>
<div class="trait"></div>
<h4>Expert (souriant) en tennis</h4>
<p>Contrary to popular belief,
lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years. Richard McClitock, Contrary to popular belief.</p>
</div> <!-- end div text-bio -->
</div>
<div class="container-activites img-fluid">
<img class="background img-fluid" src="images/tennis_background.jpg">
<div class="text-activites">
<h3>à toi de saisir la balle</h3>
<!-- <div class="trait-activite"></div>-->
<div class="activite-nom">
<?php foreach ($listeActivites as $nom): ?> <!-- boucle d'affichage des activités sportives -->
<p class="activite">
<?php echo $nom['nom_activite'] ?> <br>
<span class="horaire">Mardi-Samedi | 10 h - 13 h</span>
</p>
<?php endforeach; ?> <!-- Fin de la boucle d'affichage des activités sportives -->
</div> <!-- end div activite-nom -->
<?php if (!isset($_SESSION['identifiant_utilisateur'])) : ?>
<button type="submit" class="btn bg-danger text-white text-uppercase" data-toggle="modal" data-target="#exampleModalCenter">S'inscrire</button>
<?php else : $_SESSION['categorie'] = CATEGORIE ?>
<a class="nav-link text-white" href="membre.php">
<button type="submit" class="btn bg-danger text-white text-uppercase">S'inscrire</button>
</a>
<?php endif; ?>
</div> <!-- end div text-activite -->
</div> <!-- end container activites -->
<footer>
<?php require_once("footer.php");?> <!-- footer -->
</footer>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<script src="js/tennis.js"></script>
</body>
</html>