Advertisement
Guest User

Untitled

a guest
Oct 9th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.47 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.                 $userinfo = $requser ->fetch();
  18.                 $_SESSION['id_client']= $userinfo['id_client'];
  19.                 $_SESSION['mail']= $userinfo['mail'];
  20.                 $_SESSION['login']= $userinfo['login'];
  21.                 header("Location: profil.php?id_client=".$_SESSION['id_client']);
  22.             }
  23.  
  24.             else {
  25.                 $erreur= "Mauvais mail ou mot de passe";
  26.             }
  27.         }
  28.  
  29.         else {
  30.             $erreur="Tous les champs doivent être complétés";
  31.     }
  32. }
  33.     ?>
  34.  
  35.  
  36. <html lang="fr" xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
  37.     <head>
  38.         <title>CONNEXION</title>
  39.     </head>
  40.  
  41.     <body>
  42.         <div align="center">
  43.             <h2>CONNEXION</h2><br/>
  44.             <form method="POST" action="">
  45.                 <p>mail:</p>
  46.                 <input type="email" name="mailconnect" placeholder="Mail">
  47.                 <p>mot de passe :</p>
  48.                 <input type="password" name="mdpconnect">  
  49.                 <br/><br/> 
  50.                 <input type="submit" value="Se connecter !" name="formconnexion">
  51.             </form>
  52.  
  53.             <?php
  54.             if(isset($erreur)){
  55.                 echo '<font color="red">'.$erreur."</font>";
  56.             }
  57.             ?>
  58.         </div>
  59.     </body>
  60.     </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement