|
- <?php
- include('inc/core.php');
- if(isLogged()){
- header('Location: index.php');
- die('<a href="login.php">Cliquez ici si vous n\'êtes pas redirigé automatiquement');
- }
- if (isset($_POST['inputEmail']) && isset($_POST['inputPassword'])) {
- $login = filter_input(INPUT_POST, 'inputEmail');
- $password = hash('sha256', filter_input(INPUT_POST, 'inputPassword'));
-
- $query = $mysql->prepare('SELECT * FROM users WHERE login = :login');
- $query->bindValue(':login', $login, PDO::PARAM_STR);
- $query->execute();
- $data = $query->fetch(PDO::FETCH_BOTH);
- if ($data['password'] == $password) // Acces OK !
- {
- $_SESSION['login'] = $data['login'];
- $_SESSION['id'] = $data['idusers'];
- $_SESSION['password'] = $password;
- if (isset($_GET['r'])) {
- header('Location: ' . $_GET['r']);
- } else {
- header('Location: index.php');
- }
- } else // Acces pas OK !
- {
- $message = 'Identifiants incorrects';
- $message_type = "danger";
- }
- $query->CloseCursor();
-
- }
- ?>
- <!doctype html>
- <html lang="fr">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <meta name="description" content="">
- <meta name="author" content="">
- <link rel="icon" href="img/favicon.ico">
-
- <title>Le coin des g@mers - Identification</title>
-
- <link rel="canonical" href="https://getbootstrap.com/docs/4.0/examples/sign-in/">
-
- <!-- Bootstrap core CSS -->
- <link href="css/bootstrap.min.css" rel="stylesheet">
-
- <!-- Custom styles for this template -->
- <link href="css/login.css" rel="stylesheet">
- </head>
-
- <body class="text-center">
-
- <form class="form-signin" method="post">
- <img class="mb-4" src="https://getbootstrap.com/docs/4.0/assets/brand/bootstrap-solid.svg" alt="" width="72"
- height="72">
- <h1 class="h3 mb-3 font-weight-normal">Identification</h1>
- <?php if (isset($message)) { ?>
- <div class="alert alert-<?= $message_type ?>" role="alert">
- <?= $message ?>
- </div>
- <?php } ?>
- <label for="inputEmail" class="sr-only">Email</label>
- <input type="email" id="inputEmail" name="inputEmail" class="form-control" placeholder="Email" required autofocus>
- <label for="inputPassword" class="sr-only">Mot de passe</label>
- <input type="password" id="inputPassword" name="inputPassword" class="form-control" placeholder="Mot de passe"
- required>
- <button class="btn btn-lg btn-primary btn-block" type="submit">Connexion</button>
- <br>
- <a class="mt-5 mb-3" href="register.php">S'inscrire</a>
- <p class="mt-5 mb-3 text-muted">© 2020</p>
- </form>
-
- </body>
- </html>
|