test si connecté
This commit is contained in:
parent
a91ef3e85e
commit
f611f4997c
application
@ -6,6 +6,7 @@ class Albums extends CI_Controller {
|
|||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->load->model('model_music');
|
$this->load->model('model_music');
|
||||||
|
$this->load->library('session');
|
||||||
}
|
}
|
||||||
public function index(){
|
public function index(){
|
||||||
$albums = $this->model_music->getAlbums();
|
$albums = $this->model_music->getAlbums();
|
||||||
|
@ -44,6 +44,7 @@ class Connect extends CI_Controller {
|
|||||||
|
|
||||||
public function login()
|
public function login()
|
||||||
{
|
{
|
||||||
|
$this->load->library('form_validation');
|
||||||
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
|
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
|
||||||
$this->form_validation->set_rules('password', 'Password', 'required');
|
$this->form_validation->set_rules('password', 'Password', 'required');
|
||||||
|
|
||||||
@ -63,7 +64,7 @@ class Connect extends CI_Controller {
|
|||||||
'email' => $user['email'],
|
'email' => $user['email'],
|
||||||
'logged_in' => TRUE
|
'logged_in' => TRUE
|
||||||
]);
|
]);
|
||||||
redirect('albums');
|
redirect('albums/index');
|
||||||
} else {
|
} else {
|
||||||
$data['error'] = 'Adresse email ou mot de passe incorrect';
|
$data['error'] = 'Adresse email ou mot de passe incorrect';
|
||||||
$this->load->view('layout/header');
|
$this->load->view('layout/header');
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<h5>Albums list</h5>
|
<h5>Albums list</h5>
|
||||||
<section class="list">
|
<section class="list">
|
||||||
|
|
||||||
|
<?php if ($is_logged_in): ?>
|
||||||
|
<h1>Connecté</h1>
|
||||||
|
<?php else: ?>
|
||||||
|
<h1>Non connecté</h1>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
foreach($albums as $album){
|
foreach($albums as $album){
|
||||||
echo "<div><article>";
|
echo "<div><article>";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user