-
Notifications
You must be signed in to change notification settings - Fork 0
/
InformationsPerso.php
171 lines (147 loc) · 4.93 KB
/
InformationsPerso.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
<?php
include 'SqlConDatabase.php';
setcookie('Session_Id_user', false, 0, "", "", false, false);
setcookie('Session_type_user', false, 0, "", "", false, false);
// ***************************** FORM SE CONNECTER PHP ***********************
if (isset($_POST["Se_Connecter"])) {
$username = $_POST["username"];
$password = $_POST["password"];
// TESTER SI LOGIN ET MDP DE CLIENT
$sql1 = "SELECT * from client WHERE Email_client = '" . $username . "' AND MDP_client = '" . $password . "'";
$result1 = mysqli_query($db_handle, $sql1);
$data1 = mysqli_fetch_assoc($result1);
$IdClient = $data1['Id_client'];
$row1 = mysqli_num_rows($result1);
if ($row1 == 1) {
header("Location: Client.php");
setcookie('Session_Id_user', $IdClient, 0, "", "", false, false);
setcookie('Session_type_user', 'client', 0, "", "", false, false);
} else {
}
// TESTER SI LOGIN ET MDP DE COACH
$sql2 = "SELECT * from coach WHERE Email_coach = '" . $username . "' AND MDP_coach = '" . $password . "'";
$result2 = mysqli_query($db_handle, $sql2);
$data2 = mysqli_fetch_assoc($result2);
$IdCoach = $data2['Id_coach'];
$row2 = mysqli_num_rows($result2);
if ($row2 == 1) {
header("Location: Coach.php");
setcookie('Session_Id_user', $IdCoach, 0, "", "", false, false);
setcookie('Session_type_user', 'coach', 0, "", "", false, false);
} else {
}
// TESTER SI LOGIN ET MDP D'ADMINISTRATEUR
$sql3 = "SELECT * from administrateur WHERE Login_admin = '" . $username . "' AND MPD_admin = '" . $password . "'";
$result3 = mysqli_query($db_handle, $sql3);
$data3 = mysqli_fetch_assoc($result3);
$IdAdmin = $data3['Id_admin'];
$row3 = mysqli_num_rows($result3);
if ($row3 == 1) {
header("Location: Admin.php");
setcookie('Session_Id_user', $IdAdmin, 0, "", "", false, false);
setcookie('Session_type_user', 'administrateur', 0, "", "", false, false);
} else {
}
if (($row1 != 1) && ($row2 != 1) && ($row3 != 1)) {
echo "Erreur de LOGIN ou de PASSWORD! Veuillez réessayer ou vous créer un compte!";
}
}
// ***************************** FORM CREER UN COMPTE PHP ***********************
if (isset($_POST["Creer_Compte"])) {
include 'db_Connection.php';
$lastname = $_POST['nom'];
$firstname = $_POST['prenom'];
$email = $_POST['email'];
$tel = $_POST['tel'];
$adresse = $_POST['adresse'];
$ville = $_POST['ville'];
$codepostal = $_POST['codepostal'];
$mdp = $_POST['mdp'];
$sql = "INSERT INTO client (Nom_client, Prenom_client, Email_client, Tel_client, Adresse_client, Ville_client, CodePostal_client, MDP_client)
VALUES ('$lastname', '$firstname', '$email', '$tel', '$adresse', '$ville', '$codepostal', '$mdp')";
$res = mysqli_query($db_handle, $sql);
/*if ($res)
{
echo "Vous êtes Inscrit avec succès!";
}
else
{
echo "Problème d'inscription!";
}*/
}
?>
<!------------------------------ FIN CODE PHP ------------------------------->
<!------------------------------ DEBUT CODE HTML ------------------------------->
<!DOCTYPE html>
<html>
<head>
<title>Connexion avec PHP</title>
<meta charset="utf-8">
</head>
<body>
<h1>LOG IN FORM</h1>
<form action="#" method="POST">
<br><br><br>
<div>
<label>Username</label>
<input type="text" name="username" required>
</div>
<br><br>
<div>
<label>Password</label>
<input type="password" name="password" required>
</div>
<br><br>
<div>
<input type="submit" name="Se_Connecter">
</div>
</form>
<br><br><br>
<h1>SIGN UP FORM</h1>
<form action="#" method="POST">
<br><br><br>
<div>
<label>Nom</label>
<input type="text" name="nom" required>
</div>
<br><br>
<div>
<label>Prenom</label>
<input type="text" name="prenom" required>
</div>
<br><br>
<div>
<label>Email</label>
<input type="text" name="email" required>
</div>
<br><br>
<div>
<label>Telephone</label>
<input type="text" name="tel" required>
</div>
<br><br>
<div>
<label>Adresse</label>
<input type="text" name="adresse" required>
</div>
<br><br>
<div>
<label>Ville</label>
<input type="text" name="ville" required>
</div>
<br><br>
<div>
<label>Code Postal</label>
<input type="number" name="codepostal" required>
</div>
<br><br>
<label>Mot de Passe</label>
<input type="text" name="mdp" required>
</div>
<br><br>
<div>
<input type="submit" name="Creer_Compte">
</div>
</form>
</body>
</html>