Advertisement
Guest User

Untitled

a guest
Oct 9th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.53 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4.     include_once("params.php");
  5.  
  6.     $bdd = new PDO($dsn,$user, $password);
  7.  
  8.     if(isset($_POST['formconnexion'])){
  9.         $mailconnect = htmlspecialchars($_POST['mailconnect']);
  10.         $mdpconnect = sha1($_POST['mdpconnect']);
  11.  
  12.         if(!empty($mailconnect) AND !empty($mdpconnect)){
  13.             $requser= $bdd ->prepare("SELECT * FROM CLIENT where mail= ? AND password = ?");
  14.             $requser->execute(array($mailconnect,$mdpconnect));
  15.             $userexist = $requser->rowCount();
  16.             if($userexist == 1){
  17.                 echo $_SESSION['login'];
  18.                 echo 'test';
  19.                 $userinfo = $requser ->fetch();
  20.                 $_SESSION['id_client']= $userinfo['id_client'];
  21.                 $_SESSION['mail']= $userinfo['mail'];
  22.                 $_SESSION['login']= $userinfo['login'];
  23.                 /*header("Location: profil.php?id_client=".$_SESSION['id_client']);*/
  24.             }
  25.  
  26.             else {
  27.                 $erreur= "Mauvais mail ou mot de passe";
  28.             }
  29.         }
  30.  
  31.         else {
  32.             $erreur="Tous les champs doivent être complétés";
  33.     }
  34. }
  35.     ?>
  36.  
  37.  
  38. <html lang="fr" xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
  39.     <head>
  40.         <title>CONNEXION</title>
  41.     </head>
  42.  
  43.     <body>
  44.         <div align="center">
  45.             <h2>CONNEXION</h2><br/>
  46.             <form method="POST" action="">
  47.                 <p>mail:</p>
  48.                 <input type="email" name="mailconnect" placeholder="Mail">
  49.                 <p>mot de passe :</p>
  50.                 <input type="password" name="mdpconnect">  
  51.                 <br/><br/> 
  52.                 <input type="submit" value="Se connecter !" name="formconnexion">
  53.             </form>
  54.  
  55.             <?php
  56.             if(isset($erreur)){
  57.                 echo '<font color="red">'.$erreur."</font>";
  58.             }
  59.             ?>
  60.         </div>
  61.     </body>
  62.     </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement