Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion application/config/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
|
| $autoload['libraries'] = array('user_agent' => 'ua');
*/
$autoload['libraries'] = array('database', 'session');
$autoload['libraries'] = array('database', 'session','form_validation');

/*
| -------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion application/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
| a PHP script and you can easily do that on your own.
|
*/
$config['base_url'] = 'http://localhost:1024/m-okapi/';
$config['base_url'] = 'http://localhost/m-okapi/';

/*
|--------------------------------------------------------------------------
Expand Down
59 changes: 43 additions & 16 deletions application/controllers/Utilisateur.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,51 @@ public function form_authentification()

public function nouvel_utilisateur()
{
$nomcomplet = $this->input->post('nomcomplet');
$email = $this->input->post('email');
$login = $this->input->post('login');
$mdp = $this->input->post('mdp');
$mdpconf = $this->input->post('mdpconf');
$this->form_validation->set_rules('nomcomplet','nom complet','required',array(
'required'=>'* veuillez fournir le %s'));
$this->form_validation->set_rules('email','e-mail','required|valid_email',array(
'required'=>'* veuillez fournir le %s',
'valid_email'=>'* veuillez fournir un %s valide'));
$this->form_validation->set_rules(
'login','nom d\'utilisateur','required|is_unique[utilisateur.login]|min_length[4]|max_length[15]|alpha',array(
'required'=>'* veuillez fournir le %s',
'is_unique'=>'* %s déja utilisé',
'min_length'=>'* %s trop court',
'max_length'=>'* %s trop long',
'alpha'=>'* %s invalide'));
$this->form_validation->set_rules('mdp','mot de passe','required|min_length[8]',array(
'required'=>'* veuillez fournir un %s',
'min_length'=>'* %s trop court'));
$this->form_validation->set_rules('mdpconf','confirmation mot de passe','required|matches[mdp]',array(
'required'=>'* veuillez confirmer le mot de passe',
'matches'=>'* mots de passe non-identiques'));

$data = array(
'nomcomplet' => $nomcomplet,
'email' => $email,
'login' => $login,
'mdp' => $mdp,
'etat' => FALSE
);
if($this->form_validation->run() == TRUE)
{
$nomcomplet = $this->input->post('nomcomplet');
$email = $this->input->post('email');
$login = $this->input->post('login');
$mdp = $this->input->post('mdp');
$mdpconf = $this->input->post('mdpconf');

$this->load->model('UtilisateurModel');
$this->UtilisateurModel->creer_utilisateur($data);

$this->load->view('utilisateur/inscription_success');
$data = array(
'nomcomplet' => $nomcomplet,
'email' => $email,
'login' => $login,
'mdp' => $mdp,
'etat' => FALSE
);

$this->load->model('UtilisateurModel');
$this->UtilisateurModel->creer_utilisateur($data);

$this->load->view('utilisateur/inscription_success');

}
else
{
$this->load->view('utilisateur/form_inscription');
}
}

public function connexion()
Expand Down
40 changes: 30 additions & 10 deletions application/views/utilisateur/form_inscription.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
<head>
<style type="text/css"></style>
</head>
<h1>Créer votre compte M-OKAPI</h1>
<?php echo form_error('utilisateur/nouvel_utilisateur'); ?>

<form method="post" action="<?php echo site_url('utilisateur/nouvel_utilisateur') ?>">
Nom complet:
<input name="nomcomplet" /><br/>
Email:
<input name="email" /><br/>
Login:
<input name="login" /><br/>
Mot de passe:
<input type="password" name="mdp" /><br/>
Confirmer:
<input type="password" name="mdpconf" /><br/>

<strong>Nom complet:</strong>
<input name="nomcomplet" value="<?php echo set_value('nomcomplet'); ?>"/>
<?php echo '<em style="color:red">'.form_error('nomcomplet').'</em>'; ?> <br/>


<strong>Email:</strong>
<input name="email" value="<?php echo set_value('email'); ?>"/>
<?php echo '<em style="color:red">'.form_error('email').'</em>'; ?>
<br/>

<strong>Login:</strong>
<input name="login" value="<?php echo set_value('login'); ?>"/>
<?php echo '<em style="color:red">'.form_error('login').'</em>'; ?>
<br/>

<strong>Mot de passe:</strong>
<input type="password" name="mdp" value="<?php echo set_value('mdp'); ?>"/>
<?php echo '<em style="color:red">'.form_error('mdp').'</em>'; ?>
<br/>

<strong>Confirmer</strong>
<input type="password" name="mdpconf" value="<?php echo set_value('mdpconf'); ?>"/>
<?php echo '<em style="color:red">'.form_error('mdpconf').'</em>'; ?> <br/>

<input type="submit" value="Créer" />
<a href="<?php echo site_url('utilisateur/form_authentification') ?>">J'ai déjà un compte</a>
</form>