Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $bdd = new PDO('mysql:host=************************;dbname=***********************', '******', '*********');
- if(isset($_POST['forminscription'])) {
- $pseudo = htmlspecialchars($_POST['pseudo']);
- $mail = htmlspecialchars($_POST['mail']);
- $mail2 = htmlspecialchars($_POST['mail2']);
- $mdp = sha1($_POST['mdp']);
- $mdp2 = sha1($_POST['mdp2']);
- if(!empty($_POST['pseudo']) AND !empty($_POST['mail']) AND !empty($_POST['mail2']) AND !empty($_POST['mdp']) AND !empty($_POST['mdp2'])) {
- $pseudolength = strlen($pseudo);
- if($pseudolength <= 255) {
- if($mail == $mail2) {
- if(filter_var($mail, FILTER_VALIDATE_EMAIL)) {
- $reqmail = $bdd->prepare("SELECT * FROM membres WHERE mail = ?");
- $reqmail->execute(array($mail));
- $mailexist = $reqmail->rowCount();
- if($mailexist == 0) {
- if($mdp == $mdp2) {
- $longueurKey = 15;
- $key = "";
- for($i=1;$i<$longueurKey;$i++) {
- $key .= mt_rand(0,9);
- }
- $insertmbr = $bdd->prepare("INSERT INTO membres(pseudo, mail, motdepasse, avatar, confirmkey, uniqid) VALUES(?, ?, ?, ?, ?, ?)");
- $insertmbr->execute(array($pseudo, $mail, $mdp, $key, "default.jpg", uniqid()));
- $header="MIME-Version: 1.0\r\n";
- $header.='From:"TweetBook"<[email protected]>'."\n";
- $header.='Content-Type:text/html; charset="uft-8"'."\n";
- $header.='Content-Transfer-Encoding: 8bit';
- $message='
- <center><a href="http://tweetbook.no-ip.org/confirmation.php?pseudo='.urlencode($pseudo).'&key='.$key.'">Valider mon compte</a></center>
- ';
- mail($mail, "Confirmation de compte TweetBook", $message, $header);
- $erreur = "Votre compte a bien été créé ! <a href=\"login.php\">Me connecter</a>";
- } else {
- $erreur = "Vos mots de passes ne correspondent pas !";
- }
- } else {
- $erreur = "Adresse mail déjà utilisée !";
- }
- } else {
- $erreur = "Votre adresse mail n'est pas valide !";
- }
- } else {
- $erreur = "Vos adresses mail ne correspondent pas !";
- }
- } else {
- $erreur = "Votre pseudo ne doit pas dépasser 255 caractères !";
- }
- } else {
- $erreur = "Tous les champs doivent être complétés !";
- }
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>TweetBook</title>
- <link rel="stylesheet" type="text/css" href="http://getbootstrap.com/examples/signin/signin.css">
- </head>
- <body>
- <?php include("./inc/header.php"); ?>
- <div class="container">
- <center><h2>Inscription</h2></center>
- <br /><br />
- <form method="POST" action="" class="form-signin">
- <input type="text" class="form-control" placeholder="Votre pseudo" id="pseudo" name="pseudo" value="<?php if(isset($pseudo)) { echo $pseudo; } ?>" />
- <input type="email" class="form-control" placeholder="Votre mail" id="mail" name="mail" value="<?php if(isset($mail)) { echo $mail; } ?>" />
- <input type="email" class="form-control" placeholder="Confirmez votre mail" id="mail2" name="mail2" value="<?php if(isset($mail2)) { echo $mail2; } ?>" />
- <input type="password" class="form-control" placeholder="Votre mot de passe" id="mdp" name="mdp" />
- <input type="password" class="form-control" placeholder="Confirmez votre mdp" id="mdp2" name="mdp2" />
- <td align="center">
- <br />
- <input type="submit" class="btn btn-lg btn-primary btn-block" name="forminscription" value="Je m'inscris" />
- </td>
- </tr>
- </form>
- <?php
- if(isset($erreur)) {
- echo '<font color="red">'.$erreur."</font>";
- }
- ?>
- </div>
- </body>
- </html>
- <?php include("./inc/footer.php"); ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement