Skip to content
Snippets Groups Projects
Commit dbb80bcb authored by Maxime GUILLAUMIN's avatar Maxime GUILLAUMIN
Browse files

bonjour

parents
No related branches found
No related tags found
No related merge requests found
<?php
$host = "localhost";
$db_name = "sportif";
$admin = "root";
$password_admin = "";
?>
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
.inscription {
margin-top: 5px;
border-radius: 4px;
-moz-appearance: button;
-ms-appearance: button;
-o-appearance: button;
-webkit-appearance: button;
appearance: button;
text-decoration: none;
color: #000;
border: 2px solid #000;
padding: 0.2em 0.4em;
}
.inscription:hover {
background-color: #0d6efd;
color: white;
}
.b-example-divider {
height: 3rem;
background-color: rgba(0, 0, 0, .1);
border: solid rgba(0, 0, 0, .15);
border-width: 1px 0;
box-shadow: inset 0 .5em 1.5em rgba(0, 0, 0, .1), inset 0 .125em .5em rgba(0, 0, 0, .15);
}
.b-example-vr {
flex-shrink: 0;
width: 1.5rem;
height: 100vh;
}
.bi {
vertical-align: -.125em;
fill: currentColor;
}
.nav-scroller {
position: relative;
z-index: 2;
height: 2.75rem;
overflow-y: hidden;
}
.nav-scroller .nav {
display: flex;
flex-wrap: nowrap;
padding-bottom: 1rem;
margin-top: -1px;
overflow-x: auto;
text-align: center;
white-space: nowrap;
-webkit-overflow-scrolling: touch;
}
.error{
color:red;
display: none;
}
body{
background-image: url("../img/form.jpg");
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
height: 625px;
display: flex;
flex-direction: column;
}
#container{
margin: auto;
display: flex;
flex-direction: column;
align-items: center;
color: white;
}
form{
display: flex;
flex-direction: column;
margin-top: 50px;
}
form>input{
width: 300px;
border-radius: 5px;
margin: auto;
}
form>label{
margin: auto;
margin-top: 20px;
color: white;
}
#submit{
margin-top: 20px;
border-radius: 15px;
width: 100px;
}
input.typing:hover{
box-shadow: 0px 0px 5px 0px #795548;
}
header>nav>ul {
display: flex;
flex-direction: row;
justify-content: space-around;
align-items: center;
list-style: none;
}
a.no_decoration,
li.no_decoration {
text-decoration: none;
text-decoration-line: none;
color: white;
}
.fa-bell:before {
content: "\f0f3";
}
#bell {
width: 20px;
}
header>nav {
display: flex;
align-items: center;
justify-content: space-between;
}
img.rond {
border-radius: 50%;
}
img.logo_sigma {
height: 50px;
}
ul.notification>li {
margin-left: 20px;
}
header>nav {
display: flex;
flex-direction: row;
align-content: center;
align-items: center;
justify-content: space-between;
}
\ No newline at end of file
body {
font-family: 'Poppins', sans-serif;
}
#chart_container {
margin: 20px;
padding: 20px;
width: 50%;
height: 400px;
margin-top: 20px;
background-color: #fff;
border: 1px solid #ccc;
}
#top-nav-barre {
background-color: #2e2a27;
display: flex;
flex-direction: row;
justify-content: space-between;
padding: 5px;
align-items: center;
}
#side-barre {
width: 220px;
height: 900px;
padding: 5px;
padding-top: 20px;
background: #091c37;
}
.hide {
display: none;
}
.show {
display: block;
}
.onglet {
display: block;
width: 100%;
background-color: #0d274d;
border-radius: 10px;
padding: 5px;
}
.onglet>div:first-child {
display: flex;
justify-content: space-between;
align-items: center;
padding-left: 10px;
padding-right: 10px;
}
.onglet>ul {
list-style-type: none;
margin-top: 0px;
padding-left: 15px;
}
.div-onglet {
display: flex;
justify-content: space-between;
background: #091c37;
margin-top: 10px;
cursor: pointer;
}
/* Styles pour le formulaire d'ajout de session d'entraînement */
form {
margin: 20px;
padding: 20px;
border: 1px solid #ccc;
border-radius: 10px;
background-color: #f5f5f5;
width: 40%;
}
h1 {
font-size: 24px;
text-align: center;
margin-top: 0;
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 10px;
font-size: 18px;
}
input[type="date"],
input[type="time"],
input[type="number"] {
padding: 5px;
font-size: 16px;
border-radius: 5px;
border: 1px solid #ccc;
}
input[type="submit"] {
display: block;
margin-top: 20px;
padding: 10px;
font-size: 18px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
#side-barre {
width: 220px;
min-width: 220px;
height: 100%;
padding: 5px;
padding-top: 20px;
background: #091c37;
height: 100vh;
position: fixed;
top: 0px;
z-index: 0;
padding-top: 100px;
}
.hide {
display: none;
}
.show {
display: block;
}
.remove-list {
list-style: none;
padding: 0px;
}
.onglet {
display: block;
width: 100%;
background-color: #0d274d;
border-radius: 10px;
padding-top: 10px;
box-shadow: 0 0 4px 0px white;
}
.onglet>div {
color: white;
background: #0d274d;
margin-bottom: 10px;
}
.onglet>div:first-child {
display: flex;
justify-content: space-between;
align-items: center;
padding-left: 10px;
padding-right: 10px;
}
.onglet>ul {
list-style-type: none;
margin-top: 0px;
padding-left: 10px;
margin-top: 5px;
background: #17498f;
border-radius: 10px;
}
.div-onglet {
display: flex;
justify-content: space-between;
background: #091c37;
margin-top: 10px;
cursor: pointer;
}
.arrow-right::before {
content: "";
border-top: 7px solid transparent;
border-bottom: 7px solid transparent;
border-left: 7px solid rgb(255, 255, 255);
display: inline-block;
vertical-align: middle;
}
.arrow-down::before {
content: "";
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-top: 7px solid rgb(255, 255, 255);
display: inline-block;
vertical-align: middle;
}
.arrow {
display: block;
}
.center-vertical-inside {
display: flex;
align-items: center;
}
li.center-vertical-inside {
min-height: 40px;
}
.no-link {
color: white;
text-decoration: none;
}
\ No newline at end of file
#top-nav-barre {
background-color: #2e2a27;
display: flex;
flex-direction: row;
justify-content: space-between;
padding: 5px;
align-items: center;
position: fixed;
width: 100%;
top: 0px;
z-index: 1;
}
.navbarList {
list-style-type: none;
display: flex;
flex-direction: row;
justify-content: space-around;
align-items: center;
}
.navbarList>li {
margin-right: 15px;
}
.texte-propre {
color: white;
list-style-type: none;
text-decoration-line: none;
font-weight: bold;
}
#btn_burger {
height: 20px;
margin-left: 20px;
cursor: pointer;
}
.burger_menu {
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;
}
.lines {
display: block;
width: 36px;
height: 4px;
color: white;
background-color: white;
border-radius: 5px;
}
#line1 {
transform: translateY(-8px);
transform-origin: 0% 0%;
transition: transform 0.4s ease-in-out;
}
#line2 {
transition: transform 0.2s ease-in-out;
}
#line3 {
transform: translateY(8px);
transform-origin: 0% 100%;
transition: transform 0.4s ease-in-out;
}
.cross>#line1 {
transform-origin: 0% 0%;
transition: transform 0.4s ease-in-out;
transform: rotate(45deg);
position: relative;
top: 4px;
transform-origin: center;
}
.cross>#line2 {
background: #00000000;
}
.cross>#line3 {
transform-origin: 0% 0%;
transition: transform 0.4s ease-in-out;
transform: rotate(-45deg);
position: relative;
top: -4px;
transform-origin: center;
}
body {
padding-top: 70px;
}
\ No newline at end of file
let senderButton = document.getElementsByTagName("label")[2];
let errorDiv = document.getElementById("error");
let emailRegEx = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
/*********** DEBUG ***********/
// let passwdRegEx = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[0-9a-zA-Z]{8,}$/;
let passwdRegEx = /^[0-9a-zA-Z]{8,}$/ //Problème à régler
senderButton.addEventListener('click', function (e) {
e.preventDefault();
let isCorrect, erreur;
//Verifier email correct
/*********** DEBUG ***********/
isCorrect = emailRegEx.test(document.getElementById("username").value)
if (!isCorrect) {
erreur = "Email invalide";
} else {
/*********** DEBUG ***********/
isCorrect = true; //passwdRegEx.test(document.getElementById("password").value);
if (!isCorrect) {
erreur = "Mot de passe invalide";
}
}
//Si erreur afficher dans la balise error
if (!isCorrect) {
errorDiv.innerHTML = "<p class='red'>" + erreur + "</p>";
return;
}
errorDiv.innerHTML = "";
//si valide:
document.getElementById('register_form').action = "login.php";
document.getElementsByTagName('button')[0].click();
})
document.getElementById('xyz').addEventListener('submit', function (e) {
e.preventDefault();
let isCorrect, erreur;
//Verifier email correct
/*********** DEBUG ***********/
isCorrect = emailRegEx.test(document.getElementById("username").value)
if (!isCorrect) {
erreur = "Email invalide";
} else {
/*********** DEBUG ***********/
isCorrect = true; //passwdRegEx.test(document.getElementById("password").value);
if (!isCorrect) {
erreur = "Mot de passe invalide";
}
}
//Si erreur afficher dans la balise error
if (!isCorrect) {
errorDiv.innerHTML = "<p class='red'>" + erreur + "</p>";
return;
}
errorDiv.innerHTML = "";
//si valide:
document.getElementById('register_form').action = "login.php";
document.getElementsByTagName('button')[0].click();
})
\ No newline at end of file
let senderButton = document.getElementsByTagName("label")[2];
let errorDiv = document.getElementById("error");
let emailRegEx = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
/*********** DEBUG ***********/
// let passwdRegEx = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[0-9a-zA-Z]{8,}$/;
let passwdRegEx = /^[0-9a-zA-Z]{8,}$/ //Problème à régler
senderButton.addEventListener('click', function (e) {
e.preventDefault();
let isCorrect, erreur;
//Verifier email correct
/*********** DEBUG ***********/
isCorrect = emailRegEx.test(document.getElementById("username").value)
if (!isCorrect) {
erreur = "Email invalide";
} else {
/*********** DEBUG ***********/
isCorrect = true; //passwdRegEx.test(document.getElementById("password").value);
if (!isCorrect) {
erreur = "Mot de passe invalide";
}
}
//Si erreur afficher dans la balise error
if (!isCorrect) {
errorDiv.innerHTML = "<p class='red'>" + erreur + "</p>";
return;
}
errorDiv.innerHTML = "";
//si valide:
document.getElementById('register_form').action = "login.php";
document.getElementsByTagName('button')[0].click();
})
document.getElementById('xyz').addEventListener('submit', function (e) {
e.preventDefault();
//si valide:
document.getElementById('register_form').action = "newUser.php";
document.getElementsByTagName('button')[0].click();
})
\ No newline at end of file
const elements = document.getElementsByClassName('onglet');
// Au depart:
for (let i = 0; i < elements.length; i++) {
elements[i].children[1].style.display = "none";
}
for (let i = 0; i < elements.length; i++) {
elements[i].addEventListener('click', function(e) {
e.preventDefault();
if (this.children[1].style.display === "none") {
this.children[1].style.display = "block";
this.children[0].children[1].classList = ["arrow-down"];
} else {
this.children[1].style.display = "none";
this.children[0].children[1].classList = ["arrow-right"];
}
})
}
\ No newline at end of file
let burger_button = document.getElementById("btn_burger");
let nav_to_hide = document.getElementById("side-barre");
burger_button.addEventListener('click', function(e) {
e.preventDefault();
if (nav_to_hide.className == "show") {
nav_to_hide.className = "hide";
burger_button.className = "burger_menu";
} else {
nav_to_hide.className = "show";
burger_button.className = "cross";
}
})
\ No newline at end of file
<?php
session_start();
// Récupérer l'identifiant de l'utilisateur à partir de la variable de session
// Récupération des données du formulaire
$date = $_POST['date'];
$duree = $_POST['duree'];
$distance = $_POST['distance'];
$user_id = $_SESSION['username'];
// Connexion à la base de données
$serveur = "localhost";
$utilisateur = "root";
$mot_de_passe = "";
$base_de_donnees = "sportif";
$connexion = mysqli_connect($serveur, $utilisateur, $mot_de_passe, $base_de_donnees);
// Vérification de la connexion
if (!$connexion) {
die("Connexion à la base de données impossible : " . mysqli_connect_error());
}
// Insertion des données dans la base de données
$sql = "INSERT INTO session_train (date,username, distance, time) VALUES ('$date','$user_id', '$distance','$duree')";
mysqli_query($connexion, $sql);
header("Location: index.php");
// Fermeture de la connexion
mysqli_close($connexion);
?>
<?php
session_start();
if (!isset($_SESSION["error"])) {
$_SESSION["error"] = "";
}
if (isset($_SESSION["is_logged"]) && $_SESSION["is_logged"] === true) {
header("Location: index.php");
}
?>
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Connexion</title>
<link rel="canonical" href="https://getbootstrap.com/docs/5.2/examples/sign-in/">
<link href="CSS/reset.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<meta name="theme-color" content="#712cf9">
<link rel="stylesheet" href="CSS/connexion.css">
<style>
.red {
color: red;
}
</style>
</head>
<body class="text-center" style="height: 625px; display: flex;
flex-direction: column;
align-items: center;">
<main class="form-signin w-100 m-auto">
<form style="width: 400px; margin: auto;" method="post" action="login.php" id="register_form">
<h1 class="h3 mb-3 fw-normal">S'identifier</h1>
<div class="form-floating">
<input type="email" class="form-control" name="username" id="username" placeholder="name@example.com">
<label for="identifier">Adresse mail</label>
</div>
<div class="form-floating">
<input minlength="5" type="password" class="form-control" name="password" id="password"
placeholder="Password">
<label for="password">Mot de passe</label>
</div>
<label class="w-100 btn btn-lg btn-primary">Connexion</label>
<button style="display: none;" type="submit" id="xyz"></button>
</form>
<a class="inscription" href="inscription.php">INSCRIPTION</a>
<div id="error">
<p class="red">
<?php echo $_SESSION["error"]; ?>
</p>
</div>
</main>
<script type="text/javascript" src="JS/connexion.js"></script>
</body>
</html>
<?php
session_start();
$_SESSION['is_logged'] = false;
$_SESSION['username'] = '';
session_destroy();
echo "Deconecté";
header("Location: connexion.php");
?>
<?php
// Connexion à la base de données
$serveur = "localhost";
$utilisateur = "root";
$mot_de_passe = "";
$base_de_donnees = "sportif";
$connexion = mysqli_connect($serveur, $utilisateur, $mot_de_passe, $base_de_donnees);
// Vérification de la connexion à la base de données
if (!$connexion) {
die("Connexion échouée: " . mysqli_connect_error());
}
// Récupération du mois depuis la requête HTTP GET
if (isset($_GET['month'])) {
$month = $_GET['month'];
} else {
$month = date('n'); // Mois en cours
}
// Exécution de la requête SQL
$sql = "SELECT date, distance, time FROM session_train WHERE username = 'davidhill@isima.fr' AND MONTH(date) = $month";
$result = mysqli_query($connexion, $sql);
// Stockage des résultats dans un tableau
$data = array();
while ($row = mysqli_fetch_array($result)) {
$duree = strtotime($row['time']) - strtotime('00:00:00');
$temps_en_secondes = intval($duree);
$temps_en_heures = $temps_en_secondes / 3600;
$vitesse_moyenne = $row['distance'] / $temps_en_heures;
$data[] = array('date' => $row['date'], 'distance' => $row['distance'], 'vitesse' => $vitesse_moyenne);
}
// Fermeture de la connexion à la base de données
mysqli_close($connexion);
// Renvoi des données au format JSON
echo json_encode($data);
?>
graph.js 0 → 100644
// Fonction pour récupérer les données via une requête AJAX
function getData(month) {
return fetch(`get_data.php?month=${month}`)
.then(response => response.json())
.catch(error => {
console.log('Erreur lors de la récupération des données : ' + error.message);
});
}
// Fonction pour dessiner le graphique avec les données
function drawChart(data) {
let labels = [];
let distances = [];
let vitesses = [];
for (let i = 0; i < data.length; i++) {
labels.push(data[i].date);
distances.push(data[i].distance);
vitesses.push(data[i].vitesse);
}
let ctx = document.getElementById('myChart').getContext('2d');
let chart = new Chart(ctx, {
type: 'bar',
data: {
labels: labels,
datasets: [{
label: 'Distance parcourue (km)',
data: distances,
backgroundColor: 'rgba(0, 119, 204, 0.3)',
borderColor: 'rgba(0, 119, 204, 1)',
borderWidth: 1,
pointRadius: 3,
pointBackgroundColor: 'rgba(0, 119, 204, 1)',
pointHoverRadius: 5,
pointHoverBackgroundColor: 'rgba(0, 119, 204, 1)'
},
{
label: 'Vitesse moyenne (km/h)',
data: vitesses,
type: 'line',
backgroundColor: 'rgba(255, 99, 132, 0.3)',
borderColor: 'rgba(255, 99, 132, 1)',
borderWidth: 1,
pointRadius: 3,
pointBackgroundColor: 'rgba(255, 99, 132, 1)',
pointHoverRadius: 5,
pointHoverBackgroundColor: 'rgba(255, 99, 132, 1)'
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
}
// Fonction pour mettre à jour le graphique avec de nouvelles données
function updateGraph(month) {
getData(month).then(function (data) {
let ctx = document.getElementById('myChart').getContext('2d');
ctx.canvas.parentNode.removeChild(ctx.canvas);
let canvas = document.createElement('canvas');
canvas.id = 'myChart';
document.getElementById('chart_container').appendChild(canvas);
drawChart(data);
}).catch(function (error) {
console.log('Erreur lors de la récupération des données : ' + error.message);
});
}
// Récupération du select
let monthSelect = document.getElementById('month-select');
// Écouteur d'événement pour mettre à jour le graphique lorsqu'une nouvelle option est sélectionnée
monthSelect.addEventListener('change', function () {
const month = document.getElementById('month-select').value;
updateGraph(month);
});
<?php
function hello(){
$conn = mysqli_connect("localhost", "root", "", "sportif");
if (mysqli_connect_errno()) {
echo "Erreur de connexion à la base de données: " . mysqli_connect_error();
exit();
}
$username = $_SESSION['username'];
$query = "SELECT name,firstname FROM login WHERE username = '$username'";
$result = mysqli_query($conn, $query);
if (!$result) {
echo "Erreur d'exécution de la requête SQL: " . mysqli_error($conn);
exit();
}
$row = mysqli_fetch_assoc($result);
$_SESSION['name'] = $row['name'];
$_SESSION['firstname'] = $row['firstname'];
mysqli_close($conn);
}
?>
index.php 0 → 100644
<?php
session_start();
if (!isset($_SESSION['is_logged']) || $_SESSION['is_logged'] != true) {
header('Location: connexion.php');
die();
}
?>
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="CSS/reset.css">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link rel="stylesheet" href="CSS/index.css">
<link rel="stylesheet" href="CSS/top-barre.css">
<link rel="stylesheet" href="CSS/side-barre.css">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
<title>Accueil</title>
</head>
<body>
<?php include("topbarre.html"); ?>
<?php include("sidenav.html"); ?>
<?php include("hello.php"); ?>
<main>
<div class="coucou">
<h1> <?php
hello();
echo "Bonjour " . $_SESSION['firstname'] . " " . $_SESSION['name']; ?> </h1>
</div> </br>
<form method="post" action="ajouter_entrainement.php" class="session-form">
<h2>Ajouter une session d'entraînement</h2>
<label for="date">Date :</label>
<input type="date" id="date" name="date" required>
<label for="duree">Durée :</label>
<input type="time" id="duree" name="duree" required>
<label for="distance">Distance :</label>
<input type="number" id="distance" name="distance" required>
<input type="submit" value="Ajouter la session d'entraînement">
</form>
<div id="chart_container">
<div>
<label for="month-select">Mois :</label>
<select id="month-select">
<option value="1">Janvier</option>
<option value="2">Février</option>
<option value="3">Mars</option>
<option value="4">Avril</option>
<option value="5">Mai</option>
<option value="6">Juin</option>
<option value="7">Juillet</option>
<option value="8">Août</option>
<option value="9">Septembre</option>
<option value="10">Octobre</option>
<option value="11">Novembre</option>
<option value="12">Décembre</option>
</select>
</div>
<canvas id="myChart"></canvas>
</div>
</main>
<!-- Inclure les fichiers JavaScript pour la bibliothèque Chart.js et le script pour le graphique -->
<script src="JS/top-navbarre.js"></script>
<script src="JS/sidebarre.js"></script>
<script src="JS/datarequest.js"></script>
<script src="graph.js?<?php echo rand(); ?>"></script>
<script src="graph.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</body>
</html>
<?php
session_start();
if (!isset($_SESSION["error"])) {
$_SESSION["error"] = "";
}
if (isset($_SESSION["is_logged"]) && $_SESSION["is_logged"] === true) {
header("Location: index.php");
}
?>
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Connexion</title>
<link rel="canonical" href="https://getbootstrap.com/docs/5.2/examples/sign-in/">
<link href="CSS/reset.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<meta name="theme-color" content="#712cf9">
<link rel="stylesheet" href="CSS/connexion.css">
<style>
.red {
color: red;
}
</style>
</head>
<body class="text-center" style="height: 625px; display: flex;
flex-direction: column;
align-items: center;">
<main class="form-signin w-100 m-auto">
<form style="width: 400px; margin: auto;" method="post" action="newUser.php" id="register_form">
<h1 class="h3 mb-3 fw-normal">S'inscrire</h1>
<div class="form-floating">
<input type="nom" class="form-control" name="nom" id="nom" placeholder="Nom">
<label for="identifier">Nom</label>
</div>
<div class="form-floating">
<input type="prenom" class="form-control" name="prenom" id="prenom" placeholder="Prénom">
<label for="identifier">Prénom</label>
</div>
<div class="form-floating">
<input type="email" class="form-control" name="username" id="username" placeholder="name@example.com">
<label for="identifier">Adresse mail</label>
</div>
<div class="form-floating">
<input minlength="5" type="password" class="form-control" name="password" id="password"
placeholder="Password">
<label for="password">Mot de passe</label>
</div>
<button class="w-100 btn btn-lg btn-primary" type="submit" id="xyz" >Inscription</button>
</form>
<div id="error">
<p class="red">
<?php echo $_SESSION["error"]; ?>
</p>
</div>
</main>
<script type="text/javascript" src="JS/inscription.js"></script>
</body>
</html>
\ No newline at end of file
<?php
session_start();
/************** Récupération des identifiants ****************/
if (!isset($_POST['username']) || !isset($_POST['password'])) {
$_SESSION["error"] = "Veuillez entrer un mail et un mot de passe";
header("Location: connexion.php");
die();
}
/************** Validation des identifiants *****************/
//Connexion à la base de données
include("./BDD/database.php");
try {
// mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); // DEBUG
$mysqli = new mysqli($host, $admin, $password_admin, $db_name);
/************** Vérification des données ********************/
// Sécurité
$username = filter_input(INPUT_POST, 'username');
$password = filter_input(INPUT_POST, 'password');
$username = htmlspecialchars($username);
$password = htmlspecialchars($password);
$username = mysqli_real_escape_string($mysqli, $username);
$password = mysqli_real_escape_string($mysqli, $password);
//Si correcte on peut passer à la phase suivante sinon on le vire du site
if ($username != $_POST['username'] || $_POST['password'] != $password) {
$mysqli->close();
header("Location: prisonDeLaMuerte.html");
die();
}
$sqlQuery = "SELECT * FROM login WHERE username= ?";
$stmt = $mysqli->prepare($sqlQuery);
$stmt->bind_param("s", $username);
$stmt->execute();
$result = $stmt->get_result()->fetch_assoc();
$password_base = $result["password"];
mysqli_stmt_close($stmt);
} catch (Exception $e) {
$_SESSION["error"] = "impossible de se connecter à la bdd";
die('Erreur : ' . $e->getMessage());
}
if ($password != $password_base) {
$_SESSION["error"] = "Mauvais mot de passe";
header("Location: connexion.php");
die("Mauvais mot de passe");
}
//Si valide => rediriger vers index.html
$_SESSION['is_logged'] = true;
$_SESSION['username'] = $username;
header("Location: index.php");
die("Probleme redirection");
?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment