-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathverif.php
162 lines (126 loc) · 3.72 KB
/
verif.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
<?php
include_once('lib/php/fonction.php');
if(isset($_POST['pseudo'])){
$contenu = '';
$pseudo = $_POST['pseudo'];
//on se connecte
$connection = connectBD();
if ($connection) {
try {
$req = $connection->query('SELECT * FROM clients WHERE pseudo="'.$pseudo.'"');
//$req = $pdo->query("SELECT * FROM profil WHERE pseudo='".$pseudo."'");
if($donnee=$req->fetch())
{
echo '1';
}
else{
echo "0";
}
}
//si erreur
catch(PDOException $e){
//on annule la transaction
$connection->rollback;
//on affiche les erreurs
$contenu = '<red> Erreur: Erreur lors de la requête, veuillez contacter votre administrateur!</red></br>';
$contenu .= '<red>Erreur: '.$e->getMessage().'</red></br>';
$contenu .= '<red>Erreur:'.$e->getCode().'</red></br>';
//on quitte, on arrête l'execution q'il y a du code après
exit();
}
}
else{
echo "imppossible de se connecter!";
}
}//fin if isset
if(isset($_POST['email'])){
$contenu = '';
$email = $_POST['email'];
//on se connecte
$connection = connectBD();
if ($connection) {
try {
$req = $connection->query('SELECT * FROM users WHERE email="'.$email.'"');
$req = $connection->query('SELECT * FROM clients WHERE email="'.$email.'"');
//$req = $pdo->query("SELECT * FROM profil WHERE pseudo='".$pseudo."'");
if($donnee=$req->fetch())
{
echo '1';
}
else{
echo "0";
}
}
//si erreur
catch(PDOException $e){
//on annule la transaction
$connection->rollback;
//on affiche les erreurs
$contenu = '<red> Erreur: Erreur lors de la requête, veuillez contacter votre administrateur!</red></br>';
$contenu .= '<red>Erreur: '.$e->getMessage().'</red></br>';
$contenu .= '<red>Erreur:'.$e->getCode().'</red></br>';
//on quitte, on arrête l'execution q'il y a du code après
exit();
}
}
else{
echo "imppossible de se connecter!";
}
}//fin if isset
//Autocomplete
//if (!isset($_REQUEST['term']))
//exit();
/* if the 'term' variable is not sent with the request, exit */
if ( !isset($_REQUEST['term']) ) {
exit;
}
//on se connecte
$connection = connectBD();
if ($connection) {
try {
/*$req = $connection->query('SELECT * FROM clients WHERE name LIKE "'.ucfirst($_REQUEST['term']).'%" ORDER BY id ASC LIMIT 0.10', $connection);
$data = array();
while ($row = mysql_fetch_assoc($req, MYSQL_ASSOC)) {
$data[] = array(
'label' => $row['name'],
'value' => $row['name']
);
# code...
}
$contenu = json_data($data);
flush();*/
/* retrieve the search term that autocomplete sends */
$term = trim(strip_tags($_GET['term']));
$a_json = array();
$a_json_row = array();
if ($data = $connection->query("SELECT * FROM clients WHERE name LIKE '%$term%' OR firstname LIKE '%$term%' ORDER BY name , firstname")) {
while($row = mysqli_fetch_array($data)) {
$name = htmlentities(stripslashes($row['name ']));
$firstname = htmlentities(stripslashes($row['firstname']));
$id = htmlentities(stripslashes($row['id']));
$a_json_row["id"] = $code;
$a_json_row["value"] = $name.' '.$firstname;
$a_json_row["label"] = $name.' '.$firstname;
array_push($a_json, $a_json_row);
}
}
// jQuery wants JSON data
echo json_encode($a_json);
flush();
}
//si erreur
catch(PDOException $e){
//on annule la transaction
$connection->rollback;
//on affiche les erreurs
$contenu = '<red> Erreur: Erreur lors de la requête, veuillez contacter votre administrateur!</red></br>';
$contenu .= '<red>Erreur: '.$e->getMessage().'</red></br>';
$contenu .= '<red>Erreur:'.$e->getCode().'</red></br>';
//on quitte, on arrête l'execution q'il y a du code après
exit();
}
}
else{
echo "imppossible de se connecter!";
}
?>