inscription connexion
This commit is contained in:
parent
a27deb8ff4
commit
5089f0cd33
@ -58,7 +58,7 @@ $autoload['packages'] = array();
|
||||
|
|
||||
| $autoload['libraries'] = array('user_agent' => 'ua');
|
||||
*/
|
||||
$autoload['libraries'] = array();
|
||||
$autoload['libraries'] = array('session');
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
|
@ -127,7 +127,7 @@ $config['subclass_prefix'] = 'MY_';
|
||||
| package auto-loader script in application/vendor/autoload.php.
|
||||
|
|
||||
| $config['composer_autoload'] = TRUE;
|
||||
|
|
||||
|fig.p
|
||||
| Or if you have your vendor/ directory located somewhere else, you
|
||||
| can opt to set a specific path as well:
|
||||
|
|
||||
@ -387,7 +387,7 @@ $config['sess_driver'] = 'files';
|
||||
$config['sess_cookie_name'] = 'ci_session';
|
||||
$config['sess_samesite'] = 'Lax';
|
||||
$config['sess_expiration'] = 7200;
|
||||
$config['sess_save_path'] = NULL;
|
||||
$config['sess_save_path'] = '/tmp';
|
||||
$config['sess_match_ip'] = FALSE;
|
||||
$config['sess_time_to_update'] = 300;
|
||||
$config['sess_regenerate_destroy'] = FALSE;
|
||||
|
@ -49,6 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
| Examples: my-controller/index -> my_controller/index
|
||||
| my-controller/my-method -> my_controller/my_method
|
||||
*/
|
||||
$route['Connexion/login'] ='Connexion/login';
|
||||
$route['default_controller'] = 'welcome';
|
||||
$route['404_override'] = '';
|
||||
$route['translate_uri_dashes'] = FALSE;
|
||||
|
@ -9,11 +9,25 @@ class Albums extends CI_Controller {
|
||||
}
|
||||
|
||||
public function index(){
|
||||
$albums = $this->model_music->getAlbums();
|
||||
$genre = $this->model_music->getGenre();
|
||||
$albums = $this->model_music->getAlbums($genre);
|
||||
$playlists = $this->model_music->getPlaylist();
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('albums_list', ['albums' => $albums, 'playlists' => $playlists]);
|
||||
$this->load->view('layout/footer');
|
||||
|
||||
$selectedGenre = '0';
|
||||
$search = '';
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
if(isset($_POST['Genre'])){
|
||||
$selectedGenre = $_POST['Genre'];
|
||||
}
|
||||
}
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
if(isset($_POST['recherche'])){
|
||||
$search = $_POST['recherche'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function view($album_id){
|
||||
|
51
ci/application/controllers/Connexion.php
Normal file
51
ci/application/controllers/Connexion.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?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(){
|
||||
$this->load->view('layout/connexion.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(){
|
||||
//$this->load->view('layout/header');
|
||||
$this->load->view('login');
|
||||
//$this->load->view('layout/footer');
|
||||
}
|
||||
public function login() {
|
||||
|
||||
$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);
|
||||
$this->load->view('layout/header');
|
||||
redirect('albums');
|
||||
} else {
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('login');
|
||||
$this->load->view('layout/footer');
|
||||
echo "Invalid login or password";
|
||||
}
|
||||
}
|
||||
}
|
15
ci/application/controllers/Deconnexion.php
Normal file
15
ci/application/controllers/Deconnexion.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Deconnexion extends CI_Controller {
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->load->model('model_music');
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$this->session->unset_userdata('logged');
|
||||
$this->session->sess_destroy();
|
||||
redirect('albums');
|
||||
}
|
||||
}
|
33
ci/application/controllers/Enregistrer.php
Normal file
33
ci/application/controllers/Enregistrer.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Enregistrer extends CI_Controller{
|
||||
|
||||
public function __construct(){
|
||||
parent ::__construct();
|
||||
$this->load->model('model_music');
|
||||
}
|
||||
public function index(){
|
||||
//$this->load->view('layout/header');
|
||||
$this->load->view('SignUp');
|
||||
//$this->load->view('layout/footer');
|
||||
}
|
||||
public function SignUp() {
|
||||
$pseudo = '';
|
||||
$login = '';
|
||||
$password = '';
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
if(isset($_POST['login']) && isset($_POST['password']) && isset($_POST['pseudo'])){
|
||||
$pseudo = $_POST['pseudo'];
|
||||
$login = $_POST['login'];
|
||||
$password = $_POST['password'];
|
||||
}
|
||||
}
|
||||
$this->model_music->SignUp($pseudo,$login,$password);
|
||||
$this->session->set_userdata('logged', true);
|
||||
$this->load->view('layout/header');
|
||||
redirect('albums');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,14 +0,0 @@
|
||||
<?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(){
|
||||
$this->load->view('layout/connexion');
|
||||
}
|
||||
|
||||
}
|
@ -5,19 +5,33 @@ class Model_music extends CI_Model {
|
||||
$this->load->database();
|
||||
}
|
||||
|
||||
public function getAlbums(){
|
||||
$query = $this->db->query(
|
||||
"SELECT album.name,album.id,year,artist.name as artistName, genre.name as genreName,jpeg
|
||||
FROM album
|
||||
JOIN artist ON album.artistid = artist.id
|
||||
JOIN genre ON genre.id = album.genreid
|
||||
JOIN cover ON cover.id = album.coverid
|
||||
ORDER BY year
|
||||
"
|
||||
);
|
||||
return $query->result();
|
||||
public function getAlbums($selectedGenre) {
|
||||
if ($selectedGenre == '0') {
|
||||
$query = $this->db->query(
|
||||
"SELECT album.name, album.id, year, artist.name as artistName, genre.name as genreName, jpeg
|
||||
FROM album
|
||||
JOIN artist ON album.artistid = artist.id
|
||||
JOIN genre ON genre.id = album.genreid
|
||||
JOIN cover ON cover.id = album.coverid
|
||||
ORDER BY year"
|
||||
);
|
||||
} else {
|
||||
$query = $this->db->query(
|
||||
"SELECT album.name, album.id, year, artist.name as artistName, genre.name as genreName, jpeg
|
||||
FROM album
|
||||
JOIN artist ON album.artistid = artist.id
|
||||
JOIN genre ON genre.id = album.genreid
|
||||
JOIN cover ON cover.id = album.coverid
|
||||
WHERE album.genreId = ?
|
||||
ORDER BY year",
|
||||
array($selectedGenre)
|
||||
);
|
||||
}
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
|
||||
public function getArtists(){
|
||||
$query = $this->db->query(
|
||||
"SELECT artist.id, artist.name
|
||||
@ -87,6 +101,15 @@ class Model_music extends CI_Model {
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function getGenre(){
|
||||
$query = $this->db->query(
|
||||
"SELECT genre.id,genre.name
|
||||
FROM genre
|
||||
"
|
||||
);
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function getAlbumsOfArtist($artist_id){
|
||||
$query = $this->db->query(
|
||||
"SELECT album.name, album.id, album.year, genre.name as genreName, cover.jpeg
|
||||
@ -100,6 +123,69 @@ class Model_music extends CI_Model {
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function getLogin($login,$password){
|
||||
$query = $this->db->query(
|
||||
"SELECT *
|
||||
FROM Login
|
||||
WHERE mail = '$login' AND MotDePasse = '$password'"
|
||||
);
|
||||
return $query->result();
|
||||
}
|
||||
public function SignUp($pseudo,$login,$password){
|
||||
$query = $this->db->query(
|
||||
"INSERT INTO `Login`(`pseudo`, `mail`, `MotDePasse`)
|
||||
VALUES ('$pseudo','$login','$password')"
|
||||
);
|
||||
}
|
||||
public function searchAlbums($search,$selectedGenre){
|
||||
if($search == '' AND $selectedGenre == '0'){
|
||||
$query = $this->db->query(
|
||||
"SELECT album.name,album.id,year,artist.name as artistName, genre.name as genreName,jpeg
|
||||
FROM album
|
||||
JOIN artist ON album.artistid = artist.id
|
||||
JOIN genre ON genre.id = album.genreid
|
||||
JOIN cover ON cover.id = album.coverid
|
||||
ORDER BY year
|
||||
",
|
||||
);
|
||||
}elseif($search == ''){
|
||||
$query = $this->db->query(
|
||||
"SELECT album.name,album.id,year,artist.name as artistName, genre.name as genreName,jpeg
|
||||
FROM album
|
||||
JOIN artist ON album.artistid = artist.id
|
||||
JOIN genre ON genre.id = album.genreid
|
||||
JOIN cover ON cover.id = album.coverid
|
||||
WHERE album.genreId = $selectedGenre
|
||||
ORDER BY year
|
||||
",
|
||||
);
|
||||
}elseif($selectedGenre == '0' AND $search !=''){
|
||||
$query = $this->db->query(
|
||||
"SELECT album.name,album.id,year,artist.name as artistName, genre.name as genreName,jpeg
|
||||
FROM album
|
||||
JOIN artist ON album.artistid = artist.id
|
||||
JOIN genre ON genre.id = album.genreid
|
||||
JOIN cover ON cover.id = album.coverid
|
||||
WHERE album.name LIKE '%$search%'
|
||||
ORDER BY year
|
||||
",
|
||||
);
|
||||
}
|
||||
else{
|
||||
$query = $this->db->query(
|
||||
"SELECT album.name,album.id,year,artist.name as artistName, genre.name as genreName,jpeg
|
||||
FROM album
|
||||
JOIN artist ON album.artistid = artist.id
|
||||
JOIN genre ON genre.id = album.genreid
|
||||
JOIN cover ON cover.id = album.coverid
|
||||
WHERE album.name LIKE '%$search%' AND album.genreId = $selectedGenre
|
||||
ORDER BY year
|
||||
",
|
||||
);
|
||||
}
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function addSongToPlaylist($songName, $playlistId){
|
||||
$query = $this->db->query(
|
||||
"INSERT INTO SongPlaylist (id, name) VALUES (?, ?)",
|
||||
|
6
ci/application/views/Enregistrement.php
Normal file
6
ci/application/views/Enregistrement.php
Normal file
@ -0,0 +1,6 @@
|
||||
<form method="post" action="<?php echo base_url('index.php/Enregistrer/SignUp'); ?>">
|
||||
<input type="text" name="pseudo" placeholder="Pseudo" required>
|
||||
<input type="text" name="login" placeholder="Adresse mail" required>
|
||||
<input type="password" name="password" placeholder="Mot de passe" required>
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
13
ci/application/views/GenreFilter.php
Normal file
13
ci/application/views/GenreFilter.php
Normal file
@ -0,0 +1,13 @@
|
||||
<form method="post" action="albums">
|
||||
<?php
|
||||
echo "<select id='GenreId' name='Genre'>";
|
||||
echo "<option value='0'>Select genre</option>";
|
||||
foreach($genre as $genre) {
|
||||
echo "<option value='{$genre->id}'>{$genre->name}</option>";
|
||||
}
|
||||
echo "</select>";
|
||||
echo"<form class'search-bar' action='/search' method='post'>";
|
||||
echo"<input type'search' name='recherche' placeholder='Search...'>";
|
||||
?>
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
6
ci/application/views/SignUp.php
Normal file
6
ci/application/views/SignUp.php
Normal file
@ -0,0 +1,6 @@
|
||||
<form method="post" action="<?php echo base_url('index.php/Enregistrer/SignUp'); ?>">
|
||||
<input type="text" name="pseudo" placeholder="Pseudo" required>
|
||||
<input type="text" name="login" placeholder="Adresse mail" required>
|
||||
<input type="password" name="password" placeholder="Mot de passe" required>
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
@ -38,8 +38,8 @@
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="user">
|
||||
<a class="bouton" href="connexion.php">Connexion</a>
|
||||
<a class="bouton" href="html/Inscription.html">S'inscrire</a>
|
||||
<a class="bouton" <?= anchor('Connexion','Connexion'); ?>>Connexion</a>
|
||||
<a class="bouton" <?= anchor('Enregistrer','Enregistrer'); ?>>S'inscrire</a>
|
||||
</div>
|
||||
</header>
|
||||
</main>
|
||||
|
5
ci/application/views/login.php
Normal file
5
ci/application/views/login.php
Normal file
@ -0,0 +1,5 @@
|
||||
<form method="post" action="<?php echo base_url('index.php/Connexion/login'); ?>">
|
||||
<input type="text" name="login" placeholder="Adresse mail" required>
|
||||
<input type="password" name="password" placeholder="Mot de passe" required>
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
Loading…
Reference in New Issue
Block a user