-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·66 lines (58 loc) · 1.72 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
<?php
session_start();
include('functions.inc.php');
include('espace-membre/bdd_connexion.php');
if($_SESSION['logged_in'] != 'ok')
{
$errors = [];
if($_POST)
{
$emailconnect = trim(htmlspecialchars($_POST['emailconnect']));
$passwordconnect = sha1($_POST['passwordconnect']);
$end = $_POST['end'];
$errors = [];
if(!empty($emailconnect) AND !empty($passwordconnect))
{
$requser = $bdd->prepare("SELECT * FROM membres WHERE mail = ? AND password = ? ");
$requser->execute(array($emailconnect, $passwordconnect));
$userexist = $requser->rowCount();
if($userexist == 1)
{
$userinfo = $requser->fetch();
$_SESSION['id'] = $userinfo['id'];
$_SESSION['mail'] = $userinfo['mail'];
$_SESSION['logged_in'] = 'ok';
$connected = 1;
if(isset($_SESSION['id']))
{
$req = $bdd->prepare(" SELECT connected FROM membres WHERE id = ? ");
$req->execute(array($_SESSION['id']));
$result = $req->fetch();
if($result['id'] == 0)
{
$req = $bdd->prepare(" UPDATE membres SET connected = ? WHERE id = ? ");
$req->execute(array($connected, $_SESSION['id']));
}
$req = $bdd->prepare(" UPDATE membres SET last_activity = NOW() WHERE id = ? ");
$req->execute(array($_SESSION['id']));
}
sleep(3);
header("Location: index.php");
}
else
{
$errors['pb-connexion'] = "Mauvais email ou mauvais mot de passe.";
}
}
else
{
$errors['empty'] = "Tous les champs doivent être complétés !";
}
}
include('espace-membre/connexion.view.php');
}
else
{
include('prototype.view.php');
}
?>