This repository has been archived by the owner on Jan 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
106 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
$login = filter_input(INPUT_POST, 'login', FILTER_SANITIZE_STRING); | ||
$mdp = filter_input(INPUT_POST, 'mdp', FILTER_SANITIZE_STRING); | ||
|
||
|
||
|
||
if ($login && $mdp){ | ||
|
||
$bdd = new PDO('mysql:host=localhost;dbname=afpa-bay;charset=utf8', 'root', 'admin'); | ||
$stmt = $bdd->prepare('SELECT * FROM utilisateur WHERE login = :login'); | ||
$stmt->bindValue(':login', $login); | ||
$stmt->execute(); | ||
$utilisateur = $stmt->fetch(); | ||
if (!$utilisateur){ | ||
echo '<p class="alert">humm, pas trouvé d\'utilisateur </p>'.$login; | ||
require('login.php'); | ||
}else{ | ||
if (!password_verify($mdp, $utilisateur['mdp'])){ | ||
echo '<p class="alert">humm, le mot de passe est pas bon</p>'; | ||
require('login.php'); | ||
}else{ | ||
//ça semble ok, on mlet des choses dans la variable de session | ||
$_SESSION['user_id'] = $utilisateur['id']; | ||
$_SESSION['current_user'] = $utilisateur['login']; | ||
//on redirige | ||
header("Location: index.php",true,303); | ||
} | ||
} | ||
|
||
|
||
|
||
}else{ | ||
echo '<p class="alert">humm bah si tu saisi pas ton login +mdp comment je peux savoir si tu es membre ?</p>'; | ||
require('login.php'); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
<form id="film-form" action="index.php?page=login-handler" method="post"> | ||
|
||
<label for="titre">login :</label> | ||
<input type="text" name="login" placeholder="login" required/> | ||
<label for="titre">mot de passe :</label> | ||
<input type="text" name="mdp" placeholder="mot de passe" required/> | ||
<input type="submit" name="ok" value="ok"/> | ||
|
||
</form> | ||
|
||
<?php | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
session_destroy(); | ||
|
||
header('Location: index.php'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
-- https://www.phpmyadmin.net/ | ||
-- | ||
-- Host: localhost:3306 | ||
-- Generation Time: Jun 22, 2017 at 08:54 AM | ||
-- Generation Time: Jun 22, 2017 at 11:32 AM | ||
-- Server version: 5.7.18-0ubuntu0.17.04.1 | ||
-- PHP Version: 7.0.18-0ubuntu0.17.04.1 | ||
|
||
|
@@ -46,7 +46,30 @@ INSERT INTO `film` (`id`, `titre`, `auteur`, `acteurs`, `date_sortie`, `thumbnai | |
(4, 'sdcsd', 'sdc', 'sdc', 2015, NULL), | ||
(5, 'rturtu', 'rtutru', 'rtutr', 2005, NULL), | ||
(6, 'kikou des bois', 'zonote', 'talui', 2005, NULL), | ||
(7, 'sdcsdsdcsd', 'sdcsdcsdc', 'sdcsdcsdcdc', 2004, NULL); | ||
(7, 'sdcsdsdcsd', 'sdcsdcsdc', 'sdcsdcsdcdc', 2004, NULL), | ||
(8, 'taliu', 'zonote', 'pikatchou', 2005, NULL), | ||
(9, 'hgfj', 'gfj', 'fgjf', 2014, NULL), | ||
(10, 'ddg', 'dfgdfg', 'dfgdfg', 1986, NULL); | ||
|
||
-- -------------------------------------------------------- | ||
|
||
-- | ||
-- Table structure for table `utilisateur` | ||
-- | ||
|
||
CREATE TABLE `utilisateur` ( | ||
`id` int(11) NOT NULL, | ||
`login` varchar(20) NOT NULL, | ||
`mdp` varchar(256) NOT NULL, | ||
`email` varchar(256) NOT NULL | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
|
||
-- | ||
-- Dumping data for table `utilisateur` | ||
-- | ||
|
||
INSERT INTO `utilisateur` (`id`, `login`, `mdp`, `email`) VALUES | ||
(1, 'lionel', '$2y$10$jd3m6moA6rQ.p8OUuwO.UO3XAxml/Z6GW/.WxK1qzTnnK6py38sbS', '[email protected]'); | ||
|
||
-- | ||
-- Indexes for dumped tables | ||
|
@@ -58,6 +81,12 @@ INSERT INTO `film` (`id`, `titre`, `auteur`, `acteurs`, `date_sortie`, `thumbnai | |
ALTER TABLE `film` | ||
ADD PRIMARY KEY (`id`); | ||
|
||
-- | ||
-- Indexes for table `utilisateur` | ||
-- | ||
ALTER TABLE `utilisateur` | ||
ADD PRIMARY KEY (`id`); | ||
|
||
-- | ||
-- AUTO_INCREMENT for dumped tables | ||
-- | ||
|
@@ -66,7 +95,12 @@ ALTER TABLE `film` | |
-- AUTO_INCREMENT for table `film` | ||
-- | ||
ALTER TABLE `film` | ||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; | ||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11; | ||
-- | ||
-- AUTO_INCREMENT for table `utilisateur` | ||
-- | ||
ALTER TABLE `utilisateur` | ||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; | ||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; | ||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; | ||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; | ||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; |