Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. HTML :
  2.  
  3. <fieldset>
  4. <legend><h2>Se connecter pour plus de contenu</h2></legend>
  5.  
  6. <form method="POST" action ="page2.php">
  7. <input type="mail" name ="id" placeholder="Identifiant"><br/>
  8. <input type="password" name="mdp" placeholder="Mot de passe"/><br/>
  9. <input type="submit" name="valide" value="Valider" />
  10. </form>
  11.  
  12. </fieldset>
  13.  
  14. PHP :
  15.  
  16. <?php
  17. if(isset($_POST['valide']) && $_POST['valide'] == 'Valider')
  18. {
  19. if(isset($_POST['id']) && trim(htmlspecialchars($_POST['id'])) != null && isset($_POST['mdp']) && trim(htmlspecialchars($_POST['mdp'] == '1234')))
  20. {
  21. echo 'Connexion réussie';
  22. if(!session_start())
  23. {
  24. session_start();
  25. }
  26. $_SESSION['bonobo']['email'] = $_POST['id'];
  27. }
  28. else if(isset($_POST['mdp']) && $_POST['mdp'] != '1234')
  29. {
  30. echo 'Mauvais mot de passe';
  31. }
  32. }
  33.  
  34. if(isset($_SESSION['bonobo']['email']))
  35. {
  36. ?>
  37. <h1>Bonjour à tous blabla ... </h1>
  38. <?php
  39. }
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement