-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnection.php
More file actions
53 lines (43 loc) · 1.27 KB
/
connection.php
File metadata and controls
53 lines (43 loc) · 1.27 KB
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
<?php
$server='localhost';
$db='trello';
$login='root';
$mdp='';
session_start();
// connection alabdd
try {
$linkpdo = new PDO("mysql:host=$server;dbname=$db", $login, $mdp); //chemin de la base de données a ajouter avec login et mdp
}catch (Exception $e) {
die('Erreur : '.$e->getMessage());
}
//traitement de la connection
$mail = $_POST['mail'];
$pwd= $_POST['pwd'];
$req = $linkpdo->prepare('select mail , mdp from user where mail like :mail and mdp like :pwd');
$req->execute(array('mail' => $mail,
'pwd' => $pwd));
$data= $req -> fetch();
// si pas trouvé dansla bdd
if($data == null){
?>
<script type="text/javascript">
window.alert("vos information n'on pas permis de vous identifier");
document.location.href="http://localhost/scan/index.php";
</script>
<?php
}
else{
$_SESSION['mail']=$mail;
$_SESSION['pwd']=$pwd;
// recupere si le compte est admin ou pas
$req = $linkpdo -> prepare('select admin from user where mail like :mail and mdp like :pwd');
$req->execute(array('mail' => $mail , 'pwd' => $pwd));
$data = $req -> fetch();
$data = $data[0];
if($data == 0 ){
header("Location: compte.php");
}else{
header("Location: compteAdmin.php");
}
}
?>