Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $bdd = new PDO('mysql:host=127.0.0.1;dbname=siteweb', 'root', '');
- if(isset($_POST) AND !empty($_POST)){
- if (!empty(htmlspecialchars($_POST['user'])) AND !empty(htmlspecialchars($_POST['mdp']))) {
- $req = $bdd->prepare('SELECT * FROM users WHERE pseudo = :user AND password = :mdp ');
- $req->execute([
- 'user' => $_POST['user'],
- 'mdp' => $_POST['mdp']
- ]);
- $user = $req->fetch();
- if($user){
- session_start();
- $_SESSION['admin'] = $_POST['user'];
- header('location:index.php');
- } else {
- $error = 'Identifiants incorrects !';
- }
- } else {
- $error = 'Veuillez remplir tous les champs !';
- }
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>ToinePanel - Connection</title>
- <link rel="stylesheet" type="text/css" href="css/main.css">
- </head>
- <body>
- <div class="form-">
- <h2>ToinePanel</h3>
- <p>Veuillez vous connectez:</p>
- <?php if(isset($error)){ echo "<div class='error'>" . $error . "</div> <br />";} ?>
- <form method="POST">
- <input type="text" name="user" required placeholder="Utilisateur" class="chp">
- <input type="password" name="mdp" required placeholder="Mot de Passe" class="chp">
- <input type="submit" name="submit" value="Se connecter" class="submit">
- </form>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement