forked from ghouar-t/SaeDEV2.2
112 lines
3.4 KiB
PHP
112 lines
3.4 KiB
PHP
|
<?php
|
||
|
require_once('common.php');
|
||
|
session_start();
|
||
|
|
||
|
$login = $_SESSION['login'];
|
||
|
$mail = $_SESSION['mail'];
|
||
|
$role = $_SESSION['role'];
|
||
|
|
||
|
if (!empty($_POST['login']) && !empty($_POST['mail'])) {
|
||
|
$db = initDatabase();
|
||
|
$login = $_POST['login'];
|
||
|
$mail = $_POST['mail'];
|
||
|
$role = $_POST['role'];
|
||
|
$originallogin = $_SESSION['login'];
|
||
|
$originalmail = $_SESSION['mail'];
|
||
|
|
||
|
|
||
|
$verif=mysqli_query($db,"SELECT * FROM user WHERE login = '$login' ");
|
||
|
$verif2=mysqli_query($db,"SELECT * FROM user WHERE mail = '$mail' ");
|
||
|
$result = "UPDATE user SET login='$login', mail='$mail',Role='$role' WHERE login = '$originallogin' AND mail = '$originalmail'";
|
||
|
|
||
|
//if (mysqli_num_rows($verif) == 0) {
|
||
|
//if (mysqli_num_rows($verif2) == 0) {
|
||
|
if (mysqli_query($db,$result)) {
|
||
|
|
||
|
$_SESSION['login']=$login;
|
||
|
$_SESSION['role']=$role;
|
||
|
$_SESSION['mail']=$mail;
|
||
|
header('Location: ../index.php');
|
||
|
exit();
|
||
|
|
||
|
}
|
||
|
else {
|
||
|
die("erreur");
|
||
|
}
|
||
|
}
|
||
|
//else {
|
||
|
//$error_verif2 = "cette adresse mail est déjà utilisé";
|
||
|
//}
|
||
|
//}
|
||
|
//else {
|
||
|
//$error_verif = "ce login est déjà utilisé";
|
||
|
//}
|
||
|
//}
|
||
|
?>
|
||
|
<html lang="fr">
|
||
|
<head>
|
||
|
<script language="javascript" src="JavaScript/déconnexion.js"></script>
|
||
|
<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="../index.php" class="categorie">Page d'accueil</a>
|
||
|
<a href='events.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>
|
||
|
<input type="text" id="login" name="login" required value="<?php if (isset($login)) {echo $login;} ?>"><br>
|
||
|
<br><label for="password">Adresse mail :</label><br>
|
||
|
<input type="email" id="mail" name="mail" value="<?php if (isset($mail)) {echo $mail;} ?>"><br>
|
||
|
|
||
|
<br><label for="role">Role :</label><br>
|
||
|
<select id="role" name="role" value="<?php $role; ?>" required>
|
||
|
<?php
|
||
|
if ($role=="spectator") {
|
||
|
echo "<option value='spectator' selected>Spectator</option>";
|
||
|
echo "<option value='athlete'>Athlete</option>";
|
||
|
echo "<option value='organizer'>Organizer</option>";
|
||
|
}
|
||
|
if ($role=="athlete") {
|
||
|
echo "<option value='spectator'>Spectator</option>";
|
||
|
echo "<option value='athlete' selected>Athlete</option>";
|
||
|
echo "<option value='organizer'>Organizer</option>";
|
||
|
}
|
||
|
if ($role=="organizer") {
|
||
|
echo "<option value='spectator'>Spectator</option>";
|
||
|
echo "<option value='athlete'>Athlete</option>";
|
||
|
echo "<option value='organizer' selected>Organizer</option>";
|
||
|
}
|
||
|
?>
|
||
|
</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>
|