Modification du formulaire d'inscription

This commit is contained in:
stiti 2024-05-24 23:36:27 +02:00
parent 664c17410e
commit d69c8fe37a
3 changed files with 59 additions and 28 deletions

View File

@ -16,8 +16,10 @@ class Utilisateur extends CI_Controller {
$this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[utilisateur.email]'); $this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[utilisateur.email]');
$this->form_validation->set_rules('nom', 'Nom', 'required'); $this->form_validation->set_rules('nom', 'Nom', 'required');
$this->form_validation->set_rules('prenom', 'Prénom', 'required'); $this->form_validation->set_rules('prenom', 'Prénom', 'required');
$this->form_validation->set_rules('telephone', 'Téléphone', 'max_length[20]'); $this->form_validation->set_rules('password', 'Mot de passe', 'required|min_length[8]|max_length[64]', array(
$this->form_validation->set_rules('password', 'Mot de passe', 'required|min_length[6]'); 'min_length' => 'Le {field} doit contenir au moins {param} caractères.',
'max_length' => 'Le {field} ne doit pas dépasser {param} caractères.'
));
if ($this->form_validation->run() == FALSE) { if ($this->form_validation->run() == FALSE) {
// Charger la vue avec les erreurs // Charger la vue avec les erreurs
@ -31,7 +33,6 @@ class Utilisateur extends CI_Controller {
'email' => $this->input->post('email'), 'email' => $this->input->post('email'),
'nom' => $this->input->post('nom'), 'nom' => $this->input->post('nom'),
'prenom' => $this->input->post('prenom'), 'prenom' => $this->input->post('prenom'),
'telephone' => $this->input->post('telephone'),
'password' => password_hash($this->input->post('password'), PASSWORD_DEFAULT) // Hasher le mot de passe 'password' => password_hash($this->input->post('password'), PASSWORD_DEFAULT) // Hasher le mot de passe
); );

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Inscription</title> <title>Inscription</title>
<link rel="stylesheet" href="<?php echo base_url('assets/css/inscription.css'); ?>"> <link rel="stylesheet" href="<?php echo base_url('assets/css/inscription'); ?>">
</head> </head>
<body> <body>
<div class="container"> <div class="container">
@ -17,25 +17,11 @@
<?php echo form_open('utilisateur/inscription'); ?> <?php echo form_open('utilisateur/inscription'); ?>
<div class="form-group"> <div class="form-group">
<label for="email">Email :</label> <label for="prenom">Prénom :</label>
<input type="email" name="email" id="email" value="<?php echo set_value('email'); ?>" required> <input type="text" name="prenom" id="prenom" value="<?php echo set_value('prenom'); ?>" required>
<?php echo form_error('email'); ?> <?php echo form_error('prenom'); ?>
</div> </div>
<div class="form-group">
<label for="password">Mot de passe :</label>
<input type="password" name="password" id="password" required>
<?php echo form_error('password'); ?>
</div>
<div class="form-group">
<label for="confirm_password">Confirmer le mot de passe :</label>
<input type="password" name="confirm_password" id="confirm_password" required>
<?php echo form_error('confirm_password'); ?>
</div>
<div class="form-group"> <div class="form-group">
<label for="nom">Nom :</label> <label for="nom">Nom :</label>
<input type="text" name="nom" id="nom" value="<?php echo set_value('nom'); ?>" required> <input type="text" name="nom" id="nom" value="<?php echo set_value('nom'); ?>" required>
@ -43,19 +29,35 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="prenom">Prénom :</label> <label for="email">E-mail :</label>
<input type="text" name="prenom" id="prenom" value="<?php echo set_value('prenom'); ?>" required> <input type="email" name="email" id="email" value="<?php echo set_value('email'); ?>" required>
<?php echo form_error('prenom'); ?> <?php echo form_error('email'); ?>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="telephone">Téléphone :</label> <label for="password">Mot de passe :</label>
<input type="text" name="telephone" id="telephone" value="<?php echo set_value('telephone'); ?>"> <div class="password-wrapper">
<input type="password" name="password" id="password" required>
<button type="button" onclick="togglePasswordVisibility('password')">Afficher</button>
</div>
<?php echo form_error('password'); ?>
</div> </div>
<button type="submit" class="btn-submit">Inscription</button> <button type="submit" class="btn-submit">Inscription</button>
<?php echo form_close(); ?> <?php echo form_close(); ?>
</div> </div>
<script>
function togglePasswordVisibility(id) {
var passwordField = document.getElementById(id);
var passwordFieldType = passwordField.getAttribute('type');
if (passwordFieldType === 'password') {
passwordField.setAttribute('type', 'text');
} else {
passwordField.setAttribute('type', 'password');
}
}
</script>
</body> </body>
</html> </html>

View File

@ -30,7 +30,6 @@ label {
#email, #email,
#nom, #nom,
#prenom, #prenom,
#telephone,
#password, #password,
#confirm_password { #confirm_password {
width: 100%; width: 100%;
@ -41,6 +40,35 @@ label {
box-sizing: border-box; box-sizing: border-box;
} }
.password-wrapper {
position: relative;
display: flex;
align-items: center;
}
.password-wrapper input[type="password"],
.password-wrapper input[type="text"] {
flex: 1;
padding-right: 80px;
}
.password-wrapper button {
position: absolute;
right: 10px;
padding: 5px 10px;
background-color: #634caf;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s;
margin-bottom: 10px;
}
.password-wrapper button:hover {
background-color: rgb(54, 16, 119);
}
.btn-submit { .btn-submit {
width: 100%; width: 100%;
padding: 10px; padding: 10px;