Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <meta charset="utf-8">
- <?php
- if(isset($_POST['submit']))
- {
- $username = htmlspecialchars(trim($_POST['username']));
- $password = htmlspecialchars(trim($_POST['password']));
- $repeatpassword = htmlspecialchars(trim($_POST['repeatpassword']));
- if ($username && $password && $repeatpassword)
- {
- if (strlen($username) >= 5)
- {
- if (strlen($password) >= 5)
- {
- if ($password == $repeatpassword)
- {
- $password = md5($password);
- try {
- $bdd = new PDO('mysql:host=localhost;dbname=phpmembre;charset=utf8', 'root', 'root');
- } catch(PDOException $e) {
- die($e->getCode() . ' : ' . $e->getMessage());
- }
- try {
- $req = $bdd->prepare('INSERT INTO inscription(username,password) VALUES (:username, :password');
- $req->execute(array(
- 'username' => $username,
- 'password' => $password));
- echo 'Merci ' . $username . ' ! Votre inscription à été prise en compte !';
- } catch(PDOException $e) {
- die($e->getCode() . ' : ' . $e->getMessage());
- }
- } else {
- echo "Les mots de passe ne sont pas identiques !";
- }
- } else {
- echo "Votre mot de passe est trop court ! Il doit contenir au moins 5 caractères !";
- }
- } else {
- echo "Votre nom d'utilisateur est trop court ! Il doit contenir au moins 5 caractères !";
- }
- } else {
- echo "Veuillez saisir tous les champs !";
- }
- } ?>
- <h1>Inscription</h1>
- <form method="post" action="register.php">
- <p>Votre nom d'utilisateur</p>
- <input type="text" name="username">
- <p>Votre mot de passe</p>
- <input type="password" name="password">
- <p>Répetez votre mot de passe</p>
- <input type="password" name="repeatpassword"><br />
- <input type="submit" name="submit" value="Valider">
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement