142 lines
3.8 KiB
PHP
142 lines
3.8 KiB
PHP
<?php
|
|
require_once('common.php');
|
|
session_start();
|
|
|
|
$login = $_SESSION['login'];
|
|
$mail = $_SESSION['mail'];
|
|
$nom = $_SESSION['nom'];
|
|
$prenom = $_SESSION['prenom'];
|
|
$genre = $_SESSION['genre'];
|
|
$role = $_SESSION['role'];
|
|
|
|
if (!empty($_POST['nom']) && !empty($_POST['mail']) && !empty($_POST['prenom']) && !empty($_POST['genre'])) {
|
|
$db = initDatabase();
|
|
|
|
$mail = $_POST['mail'];
|
|
$nom = $_POST['nom'];
|
|
$prenom = $_POST['prenom'];
|
|
$genre = $_POST['genre'];
|
|
|
|
$originalmail = $_SESSION['mail'];
|
|
|
|
if ($mail != $originalmail) {
|
|
$verif=mysqli_query($db,"SELECT * FROM user WHERE mail = '$mail' ");
|
|
if (mysqli_num_rows($verif) == 0) {
|
|
$bool=true;
|
|
}
|
|
else {
|
|
$bool=false;
|
|
}
|
|
}
|
|
else {
|
|
$bool=true;
|
|
}
|
|
|
|
$result = "UPDATE user SET mail='$mail',nom='$nom', prenom='$prenom', genre='$genre' WHERE login = '$login' AND mail = '$originalmail'";
|
|
|
|
if ($bool==true) {
|
|
if (mysqli_query($db,$result)) {
|
|
|
|
$_SESSION['login'] = $login;
|
|
$_SESSION['mail'] = $mail;
|
|
$_SESSION['nom'] = $nom;
|
|
$_SESSION['prenom'] = $prenom;
|
|
$_SESSION['genre'] = $genre;
|
|
$_SESSION['role'] = $role;
|
|
header('Location: ../index.php');
|
|
exit();
|
|
|
|
}
|
|
else {
|
|
die("erreur");
|
|
}
|
|
}
|
|
else {
|
|
$error_verif = "cette adresse mail est déjà utilisé";
|
|
$mail=$originalmail;
|
|
}
|
|
}
|
|
?>
|
|
|
|
|
|
|
|
<html lang="fr">
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
<link rel="icon" href="../img/jo2024.jpg" >
|
|
<link rel="stylesheet" href="../css/style.css">
|
|
<title> Profil - Jeux Olympiques</title>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<header>
|
|
<h1 class='Hello'> Gestion du Profil </h1>
|
|
|
|
|
|
<nav>
|
|
<a href="../" class="categorie">Page d'accueil</a>
|
|
<a href='evenement.php' class='categorie'>Évènements</a>
|
|
<a href='deconnexion.php' class='categorie'>Déconnexion</a>
|
|
|
|
</nav>
|
|
</header>
|
|
|
|
|
|
<div class="page_profil">
|
|
|
|
<img class="profil" src="../img/photo-profil.png" alt="profil">
|
|
|
|
<form action="" method="post">
|
|
<br><label for="login">Login :</label><br>
|
|
<?php
|
|
echo $login;
|
|
?>
|
|
<br><br><label for="mail">Adresse mail :</label><br>
|
|
<input type="email" id="mail" name="mail" value="<?php if (isset($mail)) {echo $mail;} ?>"><br>
|
|
<?php if (isset($error_verif)) {echo "<div class='error-message'>$error_verif</div>";} ?>
|
|
<br><label for="nom">Nom :</label><br>
|
|
<input type="text" id="nom" name="nom" required value="<?php if (isset($nom)) {echo $nom;} ?>"><br>
|
|
<br><label for="prenom">Prenom :</label><br>
|
|
<input type="text" id="prenom" name="prenom" value="<?php if (isset($prenom)) {echo $prenom;} ?>"><br>
|
|
<br><label for="genre">Genre :</label><br>
|
|
<select id="genre" name="genre" value="<?php $genre; ?>" required>
|
|
<?php
|
|
if ($genre=="homme") {
|
|
echo "<option value='homme' selected>Homme</option>";
|
|
echo "<option value='femme'>Femme</option>";
|
|
echo "<option value='autre'>Autre</option>";
|
|
}
|
|
if ($genre=="femme") {
|
|
echo "<option value='homme'>Homme</option>";
|
|
echo "<option value='femme' selected>Femme</option>";
|
|
echo "<option value='autre'>Autre</option>";
|
|
}
|
|
if ($genre=="autre") {
|
|
echo "<option value='homme'>Homme</option>";
|
|
echo "<option value='femme'>Femme</option>";
|
|
echo "<option value='autre' selected>Autre</option>";
|
|
}
|
|
?>
|
|
</select><br><br>
|
|
|
|
|
|
<label for="role">Role :</label><br>
|
|
<?php
|
|
echo $role;
|
|
?>
|
|
</select><br><br>
|
|
<br><button type="submit" class="submit">Modifier les informations personnelles </button>
|
|
|
|
</form>
|
|
</div>
|
|
|
|
|
|
|
|
<footer>
|
|
<?php require_once('footer.php'); ?>
|
|
</footer>
|
|
|
|
</body>
|
|
</html>
|