Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- if(!empty($_SESSION['membre']))
- {
- header('Location: index.php');
- }
- ini_set('display_errors', 1);
- if(!empty($_POST))
- {
- extract($_POST);
- $valid = true;
- if(empty($nom))
- {
- $valid = false;
- $erreurnom = 'indiquez votre nom';
- }
- if(!empty($nom) && strlen($nom)<3)
- {
- $valid = false;
- $erreurnom = '3 caractères minimum';
- }
- if(empty($email))
- {
- $valid = false;
- $erreuremail = 'Indiquez votre e-mail';
- }
- if (!empty($email) && filter_var($email,FILTER_VALIDATE_EMAIL)===FALSE)
- {
- $valid = false;
- $erreuremail = 'Adresse e-mail invalide';
- }
- try{
- $bdd = new PDO('mysql:host=localhost;dbname=teamcom_team420' , 'teamcom_test', 'test') or die(print_r($bdd->errorInfo()));
- $bdd->exec('SET NAMES utf8');
- }
- catch(Exeption $e){
- die('Erreur:'.$e->getMessage());
- }
- $req = $bdd->prepare('SELECT id from pts_membre WHERE login=:nom');
- $req->execute(array(':nom'=>$nom));
- if($req->rowCount()>0)
- {
- $valide = false;
- $erreurid = 'Pseudo déjà utilisé';
- }
- $req = $bdd->prepare('SELECT id from pts_membre WHERE email=:email');
- $req->execute(array(':email'=>$email));
- if($req->rowCount()>0)
- {
- $valide = false;
- $erreurid = 'E-mail déjà utilisé';
- }
- $req->closeCursor();
- if($valid)
- {
- $hash = md5(rand(0,1000));
- $pass = rand(1000,5000);
- $to = $email;
- $subject = 'Inscription|Validation';
- $message = 'Merci pour votre inscription !<br />
- Vous pourrez vous connecter sur le site après avoir cliqué sur le lien d\'activation.<br />
- Voici vos identifiants, nous vous recommandons de changer le mot de passe.<br />
- Login : '.$nom.'<br />
- Mot de pass : '.$pass.'<br />
- Lien \'activation :<br />
- <a href="http://www.420-team.com/PTS/verif.php?email=' .$email. '$hash=' .$hash. '">http://www.420-team.com/PTS/verif.php?email=' .$email. '$hash=' .$hash. '</a>';
- $headers = 'From:[email protected]'."\r\n";
- $headers.='MIME-version: 1.0'."\r\n";
- $headers.='Content-type: text/html; charset=utf-8' ."\r\n";
- mail($to,$subject,$message,$headers);
- $req = $bdd->prepare('INSERT INTO pts_membre (login,pass,email,hash) VALUES (:nom,:pass,:email,:hash)');
- $req->execute(array(
- 'nom'=>$nom,
- 'pass'=>sha1($pass),
- 'email'=>$email,
- 'hash'=>$hash,
- ));
- $req->closeCursor();
- $ok = 'inscription réussie, vous allez recevoir un e-mail de confirmation';
- unset($nom);
- unset($email);
- }
- }
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>En construction</title>
- <link rel="stylesheet" type="text/css" href="css/default.css" />
- <!--[IF IE]><link rel="stylesheet" type="text/css" href="css/default-ie.css" /><![EndIf]-->
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- </head>
- <body>
- <div id="header">
- <div id="head-content">
- <div id="logo">Logo du site</div>
- <div id="menu">
- <ul>
- <li>Accueil</li>
- <li>Lien</li>
- <li>Lien</li>
- <li>Lien</li>
- </ul>
- </div>
- </div>
- </div>
- <div id="main">
- <div id="site">
- <div id="content">
- <div>
- <? if(isset($erreurid)) echo '<div class="erreurid"><p>' .$erreurid. '</p></div>' ;?>
- <? if(isset($ok)) echo '<div class="ok"><p>' .$ok. '</p></div>' ;?>
- </div>
- <div id="title-page"><h3>Devenez-membre</h3></div>
- <form action="inscription.php" method="post">
- <label for="nom">Nom :</label>
- <input type="text" name="nom" value="<? if(isset($nom)) echo $nom ?>" />
- <div class="error"><? if(isset($erreurnom)) echo $erreurnom; ?></div>
- <label for="email">Votre E-mail :</label>
- <input type="text" name="email" value="<? if(isset($email)) echo $email ?>" />
- <div class="error"><? if(isset($erreuremail)) echo $erreuremail; ?></div>
- <input type="submit" class="submit-envoyer" value="Envoyer !" />
- </form>
- <p><a href="index.php">Revenir à l'accueil</a></p>
- <?php
- error_reporting(E_ALL);
- ini_set("display_errors", 1);
- include("file_with_errors.php");
- ?>
- </div>
- <div id="right">
- <div id="login-title" class="center-right"><h2>Espace Membre</h2></div>
- <div id="login" class="center-right">
- <?php
- if(empty($_SESSION['membre']))
- { ?>
- <h2>Bonjour et bienvenue</h2>
- <p>Pour vous inscrire, c'est <a href="inscription.php">ici</a>.</p>
- <p>Sinon <a href="login.php">connectez-vous</a>.</p>
- <? }
- else
- { ?>
- <h2>Bonjour <? echo $_SESSION['membre']; ?>, ravis de te revoir !</h2>
- <p>Va personnaliser <a href="profil.php">ton profil</a>.</p>
- <? } ?>
- </div><!-- END #login -->
- </div><!-- END #right -->
- </div>
- </div>
- <div id="footer"> </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment