Advertisement
Guest User

Untitled

a guest
Jan 20th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. <?php
  2.  
  3. if(isset($_POST['forminscription'])) {
  4. $username = htmlspecialchars($_POST['username']);
  5. $mail = htmlspecialchars($_POST['mail']);
  6. $mail2 = htmlspecialchars($_POST['mail2']);
  7. $secretcode = sha1($_POST['secretcode']);
  8. $secretcode2 = sha1($_POST['secretcode2']);
  9. if(!empty($_POST['username']) AND !empty($_POST['mail']) AND !empty($_POST['mail2']) AND !empty($_POST['secretcode']) AND !empty($_POST['secretcode2'])) {
  10. $usernamelength = strlen($username);
  11. if($usernamelength >= 10) {
  12. $erreur = "Votre pseudo ne doit pas dépasser 10 caractères !";
  13. } else
  14. $checkUsername = $odb -> prepare("SELECT COUNT(*) FROM `api` WHERE `username` = :username");
  15. $checkUsername -> execute(array(':username' => $username));
  16. $countUsername = $checkUsername -> fetchColumn(0);
  17. if ($countUsername != 0) {
  18. $erreur = "Nom d\'utilisateur déjà pris";
  19. } else
  20. if($mail != $mail2) {
  21. $erreur = "Les adresses mail ne correspondent pas !";
  22. } else
  23. if(filter_var($mail, FILTER_VALIDATE_EMAIL)) {
  24. $reqmail = $odb->prepare("SELECT * FROM api WHERE email = ?");
  25. $reqmail->execute(array($mail));
  26. $mailexist = $reqmail->rowCount();
  27. if($mailexist == 1) {
  28. $erreur = "Adresse mail déjà utilisée !";
  29. } else
  30. if($secretcode != $secretcode2) {
  31. $erreur = "Les code de sécurité ne correspondent pas !";
  32. } else
  33. $insertmbr = $odb->prepare("INSERT INTO api(username, email, code) VALUES(?, ?, ?)");
  34. $insertmbr->execute(array($username, $mail, $secretcode));
  35. $validation = "Votre compte a bien été créé ! <a href=\"connexion.php\">Me connecter</a>";
  36. } else {
  37. $erreur = "Votre adresse mail n'est pas valide !";
  38. }
  39. } else {
  40. $erreur = "Tous les champs doivent être complétés !";
  41. }
  42. }
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement