Guest User

Untitled

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