Guest User

Untitled

a guest
Jan 22nd, 2011
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. <?php
  2. session_start();
  3. ini_set('display_errors', 1);
  4. if(!empty($_SESSION['membre']))
  5. {
  6. header('Location: index.php');
  7. }
  8.  
  9. if(!empty($_POST))
  10. {
  11. $valid = true;
  12. extract($_POST);
  13.  
  14. if(empty($login))
  15. {
  16. $valid = false;
  17. $erreurlogin = 'Indiquez votre login';
  18. }
  19.  
  20. if(empty($pass))
  21. {
  22. $valid = false;
  23. $erreurpass = 'Indiquez votre mot de passe';
  24. }
  25.  
  26. if($valid)
  27. {
  28. try{
  29. $bdd = new PDO('mysql:host=localhost;dbname=***' , '***', '***') or die(print_r($bdd->errorInfo()));
  30. $bdd->exec('SET NAMES utf8');
  31. }
  32. catch(Exeption $e){
  33. die('Erreur:'.$e->getMessage());
  34. }
  35.  
  36. $req = $bdd->prepare('SELECT * FROM pts_membre WHERE login=:login AND pass=:pass');
  37. $req->execute(array(
  38. 'login'=>$login,
  39. 'pass'=>sha1($pass)
  40. ));
  41. $data = $req->fetch();
  42. if($req->rowCount()==0)
  43. {
  44. $valid = false;
  45. $erreurid = 'Mauvais identifiants.';
  46. }
  47.  
  48. if($req->rowCount()>0 && $data['actif']==0)
  49. {
  50. $valid = false;
  51. $erreurid = 'Le compte n\'est pas actif, vérifiez vos mails.';
  52. }
  53. else
  54. {
  55. if($req->rowCount()>0 && $data['actif']==1)
  56. {
  57. $_SESSION['membre'] = $login;
  58. }
  59. }
  60. $reg->closeCursor();
  61. if($valid)
  62. {
  63. header('Location: profil.php');
  64. }
  65. }
  66. }
  67.  
  68. ?>
  69. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  70. <html xmlns="http://www.w3.org/1999/xhtml">
  71. <head>
  72. <title>En construction</title>
  73. <link rel="stylesheet" type="text/css" href="css/default.css" />
  74. <!--[IF IE]><link rel="stylesheet" type="text/css" href="css/default-ie.css" /><![EndIf]-->
  75. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  76. </head>
  77. <body>
  78. <div id="header">
  79. <div id="head-content">
  80. <div id="logo">Logo du site</div>
  81. <div id="menu">
  82. <ul>
  83. <li>Accueil</li>
  84. <li>Lien</li>
  85. <li>Lien</li>
  86. <li>Lien</li>
  87. </ul>
  88. </div>
  89. </div>
  90. </div>
  91. <div id="main">
  92. <div id="site">
  93. <div id="content">
  94.  
  95. </div>
  96. <div id="right">
  97. <? if(isset($erreurid)) echo '<div class="erreurid"><p>' .$erreurid. '</p></div>' ;?>
  98. <div id="login-title" class="center-right"><h2>Espace Membre</h2></div>
  99. <div id="login" class="center-right">
  100. <form action="login.php" method="post">
  101.  
  102. <label for="login">Login :</label>
  103. <input type="text" name="login" value="<? if(isset($login)) echo $login; ?>" />
  104. <div class="error"><? if(isset($erreurlogin)) echo $erreurlogin; ?></div>
  105.  
  106. <label for="pass">Pass :</label>
  107. <input type="password" name="pass" value="<? if(isset($pass)) echo $pass; ?>" />
  108. <div class="error"><? if(isset($erreurpass)) echo $erreurpass; ?></div>
  109.  
  110. <input type="submit" class="submit-envoyer" value="Connexion" />
  111.  
  112. </form>
  113. </div><!-- END #login -->
  114. </div><!-- END #right -->
  115. </div>
  116. </div>
  117. <div id="footer">&nbsp;</div>
  118. </body>
  119. </html>
Advertisement
Add Comment
Please, Sign In to add comment