<?php
session_start();
include("infos.php");
@$valider = $_POST["inscrire"];
$erreur = "";
if (isset($valider)) {
if (empty($nom)) $erreur = "Le chanmps nom est obligatoire!";
elseif (empty($prenom)) $erreur = "Le chanmps prénom est obligatoire!";
elseif (empty($pseudo)) $erreur = "Le chanmps Pseudo est obligatoire!";
elseif (empty($password)) $erreur = "Le chanmps mot de passe est obligatoire!";
elseif ($password != $passwordConf) $erreur = "Mots de passe differents!";
else {
include("confconnect.php");
$verify_pseudo = $conn->prepare("SELECT id FROM DashBoard.users WHERE pseudo=? limit 1");
$verify_pseudo->execute(array($pseudo));
$user_pseudo = $verify_pseudo->fetchAll();
if (count($user_pseudo) > 0)
$erreur = "Pseudo existe déjà!";
else {
$ins = $conn->prepare("INSERT INTO DashBoard.users(nom,prenom,pseudo,password) VALUES(?,?,?,?)");
if ($ins->execute(array($nom, $prenom, $pseudo, md5($password))))
header("location:index.php");
     }
   }
}
?>

</html>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="stylelogin.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <title>Insciption</title>
</head>
<body onLoad="document.fo.login.focus()">

    <div class="erreur"><?php echo $erreur ?></div>

<div class="container-fluid">
    <div class="row no-gutter">
        <!-- The image half -->
        <div class="col-md-6 d-none d-md-flex ">
            <img src="img/duck.gif">
        </div>


        <!-- The content half -->
<div class="col-md-6 bg-light">
    <div class="login d-flex align-items-center py-5">

    <div class="container">
                    <div class="row">
                        <div class="col-lg-10 col-xl-7 mx-auto">
                            <h3 class="display-4">Inscription</h3>
                            <form  name="form"  method="post"  action="">
                                <div class="form-group mb-3">
                                    <input  type="text"  name="nom"  placeholder="Nom"  value="<?=  $nom  ?>"  class="form-control rounded-pill border-0 shadow-sm px-4"/><br  />
                                    <input  type="text"  name="prenom"  placeholder="Prénom"  value="<?=  $prenom  ?>"  class="form-control rounded-pill border-0 shadow-sm px-4"/><br  />
                                    <input  type="text"  name="pseudo"  placeholder="Votre Pseudo"  value="<?=  $pseudo  ?>"  class="form-control rounded-pill border-0 shadow-sm px-4"/><br  />
                                </div>
                                <div class="form-group mb-3">
                                    <input  type="password"  name="password"  placeholder="Mot de passe"  class="form-control rounded-pill border-0 shadow-sm px-4 text-primary">
                                    <input  type="password"  name="passconf"  placeholder="Confirmer votre Mot de passe"  class="form-control rounded-pill border-0 shadow-sm px-4 text-primary">
                                </div>
                                <button type="submit" name="inscrire" value="S'inscrire" class="btn btn-primary btn-block text-uppercase mb-2 rounded-pill shadow-sm">Sign in</button> 
                                </div>
                            </form>
                        </div>
                    </div>
                </div><!-- End -->

            </div>
        </div><!-- End -->

    </div>
</div>

<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.1/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>