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('nom', '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[6]');
$this->form_validation->set_rules('password', 'Mot de passe', 'required|min_length[8]|max_length[64]', array(
'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) {
// Charger la vue avec les erreurs
@ -31,7 +33,6 @@ class Utilisateur extends CI_Controller {
'email' => $this->input->post('email'),
'nom' => $this->input->post('nom'),
'prenom' => $this->input->post('prenom'),
'telephone' => $this->input->post('telephone'),
'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 name="viewport" content="width=device-width, initial-scale=1.0">
<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>
<body>
<div class="container">
@ -17,24 +17,10 @@
<?php echo form_open('utilisateur/inscription'); ?>
<div class="form-group">
<label for="email">Email :</label>
<input type="email" name="email" id="email" value="<?php echo set_value('email'); ?>" required>
<?php echo form_error('email'); ?>
<label for="prenom">Prénom :</label>
<input type="text" name="prenom" id="prenom" value="<?php echo set_value('prenom'); ?>" required>
<?php echo form_error('prenom'); ?>
</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">
<label for="nom">Nom :</label>
@ -43,19 +29,35 @@
</div>
<div class="form-group">
<label for="prenom">Prénom :</label>
<input type="text" name="prenom" id="prenom" value="<?php echo set_value('prenom'); ?>" required>
<?php echo form_error('prenom'); ?>
<label for="email">E-mail :</label>
<input type="email" name="email" id="email" value="<?php echo set_value('email'); ?>" required>
<?php echo form_error('email'); ?>
</div>
<div class="form-group">
<label for="telephone">Téléphone :</label>
<input type="text" name="telephone" id="telephone" value="<?php echo set_value('telephone'); ?>">
<label for="password">Mot de passe :</label>
<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>
<button type="submit" class="btn-submit">Inscription</button>
<?php echo form_close(); ?>
</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>
</html>

View File

@ -30,7 +30,6 @@ label {
#email,
#nom,
#prenom,
#telephone,
#password,
#confirm_password {
width: 100%;
@ -41,6 +40,35 @@ label {
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 {
width: 100%;
padding: 10px;