Ajout del'inscription, connection et deconnection avec bd
This commit is contained in:
@@ -11,19 +11,14 @@ class Albums extends CI_Controller {
|
||||
$this->load->helper('html');
|
||||
$this->load->helper('url');
|
||||
$this->load->helper('form');
|
||||
$this->filter = $this->input->get('filter');
|
||||
}
|
||||
public function index(){
|
||||
|
||||
if ($this->filter == "co") {
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('new_user');
|
||||
}else{
|
||||
|
||||
$albums = $this->model_music->getAlbums();
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('albums_list',['albums'=>$albums]);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
46
codeigniter/application/controllers/ConnexionController.php
Normal file
46
codeigniter/application/controllers/ConnexionController.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class ConnexionController extends CI_Controller {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->load->helper(array('url', 'html'));
|
||||
$this->load->library('session');
|
||||
}
|
||||
|
||||
public function connexion() {
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('connexion');
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
public function authentifier() {
|
||||
|
||||
if($_SERVER["REQUEST_METHOD"] == "POST"){
|
||||
$email = $_POST['email'];
|
||||
$password = $_POST['password'];
|
||||
if($email != "" && $password != ""){
|
||||
$this->load->database();
|
||||
$query = $this->db->query("SELECT * FROM users WHERE email = '$email' AND mdp = '$password'");
|
||||
$result = $query->row(); // Récupérer la première ligne de résultat
|
||||
|
||||
if($result){ // Vérifier si l'utilisateur existe
|
||||
$this->session->set_userdata('pseudo', $result->pseudo);
|
||||
redirect('../index.php');
|
||||
} else {
|
||||
$data['error_msg'] = "Email ou mot de passe incorrect.";
|
||||
}
|
||||
}
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('connexion', $data);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
}
|
||||
|
||||
public function deconnexion() {
|
||||
$this->session->unset_userdata('pseudo');
|
||||
$this->session->sess_destroy();
|
||||
redirect('../index.php');
|
||||
}
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class InscriptionController extends CI_Controller {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->load->helper(array('url', 'html'));
|
||||
}
|
||||
|
||||
public function inscription() {
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('inscription');
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
public function traitement() {
|
||||
if(isset($_POST['ok'])){
|
||||
$this->load->database();
|
||||
|
||||
|
||||
$prenom = ucfirst(strtolower($this->input->post('prenom')));
|
||||
$nom = strtoupper($this->input->post('nom'));
|
||||
$pseudo = $this->input->post('pseudo');
|
||||
$mdp = $this->input->post('pass');
|
||||
$email = $this->input->post('email');
|
||||
|
||||
$data = array(
|
||||
'pseudo' => $pseudo,
|
||||
'nom' => $nom,
|
||||
'prenom' => $prenom,
|
||||
'mdp' => $mdp,
|
||||
'email' => $email
|
||||
);
|
||||
|
||||
$this->db->insert('users', $data);
|
||||
|
||||
$data['confirmation_message'] = "Inscription réussie ! Vous êtes maintenant inscrit.";
|
||||
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('inscription', $data);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user