From f611f4997c8246be95f4db46e040ede9d93be4f3 Mon Sep 17 00:00:00 2001 From: Vince <vi.teissier@gmail.com> Date: Mon, 3 Jun 2024 09:53:37 +0200 Subject: [PATCH] =?UTF-8?q?test=20si=20connect=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/controllers/Albums.php | 1 + application/controllers/Connect.php | 3 ++- application/views/albums_list.php | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/application/controllers/Albums.php b/application/controllers/Albums.php index 125b4e8..ba9a26d 100644 --- a/application/controllers/Albums.php +++ b/application/controllers/Albums.php @@ -6,6 +6,7 @@ class Albums extends CI_Controller { public function __construct(){ parent::__construct(); $this->load->model('model_music'); + $this->load->library('session'); } public function index(){ $albums = $this->model_music->getAlbums(); diff --git a/application/controllers/Connect.php b/application/controllers/Connect.php index 8789ffe..ad0ebdb 100644 --- a/application/controllers/Connect.php +++ b/application/controllers/Connect.php @@ -44,6 +44,7 @@ class Connect extends CI_Controller { public function login() { + $this->load->library('form_validation'); $this->form_validation->set_rules('email', 'Email', 'required|valid_email'); $this->form_validation->set_rules('password', 'Password', 'required'); @@ -63,7 +64,7 @@ class Connect extends CI_Controller { 'email' => $user['email'], 'logged_in' => TRUE ]); - redirect('albums'); + redirect('albums/index'); } else { $data['error'] = 'Adresse email ou mot de passe incorrect'; $this->load->view('layout/header'); diff --git a/application/views/albums_list.php b/application/views/albums_list.php index 0fd49bb..f7f7a3c 100644 --- a/application/views/albums_list.php +++ b/application/views/albums_list.php @@ -1,5 +1,12 @@ <h5>Albums list</h5> <section class="list"> + +<?php if ($is_logged_in): ?> + <h1>Connecté</h1> +<?php else: ?> + <h1>Non connecté</h1> +<?php endif; ?> + <?php foreach($albums as $album){ echo "<div><article>";