Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- ini_set('display_errors', 1);
- if(!empty($_SESSION['membre']))
- {
- header('Location: index.php');
- }
- if(!empty($_POST))
- {
- $valid = true;
- extract($_POST);
- if(empty($login))
- {
- $valid = false;
- $erreurlogin = 'Indiquez votre login';
- }
- if(empty($pass))
- {
- $valid = false;
- $erreurpass = 'Indiquez votre mot de passe';
- }
- if($valid)
- {
- try{
- $bdd = new PDO('mysql:host=localhost;dbname=***' , '***', '***') or die(print_r($bdd->errorInfo()));
- $bdd->exec('SET NAMES utf8');
- }
- catch(Exeption $e){
- die('Erreur:'.$e->getMessage());
- }
- $req = $bdd->prepare('SELECT * FROM pts_membre WHERE login=:login AND pass=:pass');
- $req->execute(array(
- 'login'=>$login,
- 'pass'=>sha1($pass)
- ));
- $data = $req->fetch();
- if($req->rowCount()==0)
- {
- $valid = false;
- $erreurid = 'Mauvais identifiants.';
- }
- if($req->rowCount()>0 && $data['actif']==0)
- {
- $valid = false;
- $erreurid = 'Le compte n\'est pas actif, vérifiez vos mails.';
- }
- else
- {
- if($req->rowCount()>0 && $data['actif']==1)
- {
- $_SESSION['membre'] = $login;
- }
- }
- $reg->closeCursor();
- if($valid)
- {
- header('Location: profil.php');
- }
- }
- }
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>En construction</title>
- <link rel="stylesheet" type="text/css" href="css/default.css" />
- <!--[IF IE]><link rel="stylesheet" type="text/css" href="css/default-ie.css" /><![EndIf]-->
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- </head>
- <body>
- <div id="header">
- <div id="head-content">
- <div id="logo">Logo du site</div>
- <div id="menu">
- <ul>
- <li>Accueil</li>
- <li>Lien</li>
- <li>Lien</li>
- <li>Lien</li>
- </ul>
- </div>
- </div>
- </div>
- <div id="main">
- <div id="site">
- <div id="content">
- </div>
- <div id="right">
- <? if(isset($erreurid)) echo '<div class="erreurid"><p>' .$erreurid. '</p></div>' ;?>
- <div id="login-title" class="center-right"><h2>Espace Membre</h2></div>
- <div id="login" class="center-right">
- <form action="login.php" method="post">
- <label for="login">Login :</label>
- <input type="text" name="login" value="<? if(isset($login)) echo $login; ?>" />
- <div class="error"><? if(isset($erreurlogin)) echo $erreurlogin; ?></div>
- <label for="pass">Pass :</label>
- <input type="password" name="pass" value="<? if(isset($pass)) echo $pass; ?>" />
- <div class="error"><? if(isset($erreurpass)) echo $erreurpass; ?></div>
- <input type="submit" class="submit-envoyer" value="Connexion" />
- </form>
- </div><!-- END #login -->
- </div><!-- END #right -->
- </div>
- </div>
- <div id="footer"> </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment