forked from maximesenecal/php-webapp-comptacrab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·89 lines (88 loc) · 2.87 KB
/
index.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
<?php
include 'header.php';
?>
<div class="container">
<img src="img/comptaCrab-essayez-nous.png" class="img-responsive" alt="Responsive image Essayez nous">
</div>
<?php
if(!empty($_POST)) {
$email = Securite::bdd($_POST['identification_nom']);
$password = sha1(Securite::bdd($_POST['identification_password']));
$q = array(
'email' => $email,
'password' => $password
);
$sql = 'SELECT email, pass FROM users WHERE email = :email AND pass = :password';
try{
$req = $cnx->prepare($sql);
}catch(Exception $e){
echo 'Erreur : '.$e->getMessage().'<br />';
echo 'N° : '.$e->getCode();
}
$req->execute($q);
$count = $req->rowCount($sql);
if($count == 1) {
/*
* Verifie si le compte user est actif
*/
$sql = 'SELECT email, pass FROM users WHERE email = :email AND pass = :password AND activer = 1';
$req = $cnx->prepare($sql);
$req->execute($q);
$actif = $req->rowCount($sql);
if($actif == 1) {
$_SESSION['Auth'] = array(
'email' => $email,
'password' => $password,
);
echo '
<div class="container">
<div class="row">
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<strong>Bienvenue !</strong> Vous vous êtes connecté avec succés !
</div>
</div>
</div>
';
} else {
$error_actif = ' Votre compte n\'est pas actif, veuillez vérifier vos mails pour activer votre compte.';
echo'
<div class="container">
<div class="row">
<div class="alert alert-warning alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<strong>'.Securite::html($error_actif).'</strong></p>
</div>
</div>
</div>
';
include 'identification.php';
include 'footer.php';
}
} else {
/*
* Si utilisateur est inconnu
*/
$error_unknown = ' Combinaison utilisateur/mot de passe incorrect. Veuillez rééssayer.';
echo'
<div class="container">
<div class="row">
<div class="alert alert-warning alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<strong>'.Securite::html($error_unknown).'</strong></p>
</div>
</div>
</div>
';
include 'identification.php';
include 'footer.php';
}
}else{
if(!Auth::islog()) {
include 'identification.php';
include 'footer.php';
}else{
include 'footer.php';
}
}
?>