SAEWEB2.2/ci/application/controllers/Connexion.php

40 lines
1.0 KiB
PHP
Raw Normal View History

2024-06-10 11:16:43 +02:00
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Connexion extends CI_Controller{
public function __construct(){
parent ::__construct();
$this->load->model('model_music');
}
public function index(){
2024-06-12 18:17:31 +02:00
//$this->load->view('layout/header');
2024-06-10 11:16:43 +02:00
$this->load->view('login');
2024-06-12 18:17:31 +02:00
//$this->load->view('layout/footer');
2024-06-10 11:16:43 +02:00
}
public function login() {
2024-06-10 16:12:11 +02:00
$login = '';
$password = '';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if(isset($_POST['login']) && isset($_POST['password'])){
$login = $_POST['login'];
$password = $_POST['password'];
}
}
$result = $this->model_music->getLogin($login,$password);
if (count($result) > 0) {
$this->session->set_userdata('logged', true);
2024-06-12 18:17:31 +02:00
$this->session->set_userdata('mail', $login);
2024-06-10 16:12:11 +02:00
$this->load->view('layout/header');
redirect('albums');
} else {
2024-06-12 18:17:31 +02:00
//$this->load->view('layout/header');
2024-06-10 16:12:11 +02:00
$this->load->view('login');
$this->load->view('layout/footer');
echo "Invalid login or password";
}
2024-06-10 11:16:43 +02:00
}
}