Advertisement
Guest User

Untitled

a guest
Apr 25th, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.28 KB | None | 0 0
  1. <?php
  2.  
  3. $bdd = new PDO('mysql:host=************************;dbname=***********************', '******', '*********');
  4.  
  5. if(isset($_POST['forminscription'])) {
  6. $pseudo = htmlspecialchars($_POST['pseudo']);
  7. $mail = htmlspecialchars($_POST['mail']);
  8. $mail2 = htmlspecialchars($_POST['mail2']);
  9. $mdp = sha1($_POST['mdp']);
  10. $mdp2 = sha1($_POST['mdp2']);
  11. if(!empty($_POST['pseudo']) AND !empty($_POST['mail']) AND !empty($_POST['mail2']) AND !empty($_POST['mdp']) AND !empty($_POST['mdp2'])) {
  12. $pseudolength = strlen($pseudo);
  13. if($pseudolength <= 255) {
  14. if($mail == $mail2) {
  15. if(filter_var($mail, FILTER_VALIDATE_EMAIL)) {
  16. $reqmail = $bdd->prepare("SELECT * FROM membres WHERE mail = ?");
  17. $reqmail->execute(array($mail));
  18. $mailexist = $reqmail->rowCount();
  19. if($mailexist == 0) {
  20. if($mdp == $mdp2) {
  21. $longueurKey = 15;
  22. $key = "";
  23. for($i=1;$i<$longueurKey;$i++) {
  24. $key .= mt_rand(0,9);
  25. }
  26. $insertmbr = $bdd->prepare("INSERT INTO membres(pseudo, mail, motdepasse, avatar, confirmkey, uniqid) VALUES(?, ?, ?, ?, ?, ?)");
  27. $insertmbr->execute(array($pseudo, $mail, $mdp, $key, "default.jpg", uniqid()));
  28.  
  29. $header="MIME-Version: 1.0\r\n";
  30. $header.='From:"TweetBook"<[email protected]>'."\n";
  31. $header.='Content-Type:text/html; charset="uft-8"'."\n";
  32. $header.='Content-Transfer-Encoding: 8bit';
  33. $message='
  34. <center><a href="http://tweetbook.no-ip.org/confirmation.php?pseudo='.urlencode($pseudo).'&key='.$key.'">Valider mon compte</a></center>
  35. ';
  36. mail($mail, "Confirmation de compte TweetBook", $message, $header);
  37.  
  38. $erreur = "Votre compte a bien été créé ! <a href=\"login.php\">Me connecter</a>";
  39. } else {
  40. $erreur = "Vos mots de passes ne correspondent pas !";
  41. }
  42. } else {
  43. $erreur = "Adresse mail déjà utilisée !";
  44. }
  45. } else {
  46. $erreur = "Votre adresse mail n'est pas valide !";
  47. }
  48. } else {
  49. $erreur = "Vos adresses mail ne correspondent pas !";
  50. }
  51. } else {
  52. $erreur = "Votre pseudo ne doit pas dépasser 255 caractères !";
  53. }
  54. } else {
  55. $erreur = "Tous les champs doivent être complétés !";
  56. }
  57. }
  58. ?>
  59. <!DOCTYPE html>
  60. <html>
  61. <head>
  62. <meta charset="UTF-8">
  63. <title>TweetBook</title>
  64. <link rel="stylesheet" type="text/css" href="http://getbootstrap.com/examples/signin/signin.css">
  65. </head>
  66. <body>
  67. <?php include("./inc/header.php"); ?>
  68. <div class="container">
  69. <center><h2>Inscription</h2></center>
  70. <br /><br />
  71. <form method="POST" action="" class="form-signin">
  72. <input type="text" class="form-control" placeholder="Votre pseudo" id="pseudo" name="pseudo" value="<?php if(isset($pseudo)) { echo $pseudo; } ?>" />
  73. <input type="email" class="form-control" placeholder="Votre mail" id="mail" name="mail" value="<?php if(isset($mail)) { echo $mail; } ?>" />
  74. <input type="email" class="form-control" placeholder="Confirmez votre mail" id="mail2" name="mail2" value="<?php if(isset($mail2)) { echo $mail2; } ?>" />
  75. <input type="password" class="form-control" placeholder="Votre mot de passe" id="mdp" name="mdp" />
  76. <input type="password" class="form-control" placeholder="Confirmez votre mdp" id="mdp2" name="mdp2" />
  77. <td align="center">
  78. <br />
  79. <input type="submit" class="btn btn-lg btn-primary btn-block" name="forminscription" value="Je m'inscris" />
  80. </td>
  81. </tr>
  82. </form>
  83. <?php
  84. if(isset($erreur)) {
  85. echo '<font color="red">'.$erreur."</font>";
  86. }
  87. ?>
  88. </div>
  89. </body>
  90. </html>
  91. <?php include("./inc/footer.php"); ?>
  92. </body>
  93. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement