mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 06:22:13 +01:00 
			
		
		
		
	Amélioration du code de la page de connexion
This commit is contained in:
		@@ -1,97 +1,100 @@
 | 
			
		||||
<?php
 | 
			
		||||
require_once "header.php";
 | 
			
		||||
 | 
			
		||||
if (isset($error_message) && $error_message)
 | 
			
		||||
    echo "<h2>Erreur : " . $error_message . "</h2>";
 | 
			
		||||
 | 
			
		||||
if (isset($error_message) && $error_message === FALSE) {
 | 
			
		||||
	if (isset($_GET["mdp_oublie"]))
 | 
			
		||||
		echo "Le mail de récupération de mot de passe a bien été envoyé.";
 | 
			
		||||
	else if (isset($_POST["reset_password"]))
 | 
			
		||||
		echo "Le mot de passe a bien été changé. Vous pouvez désormais vous connecter.";
 | 
			
		||||
	else if (isset($_GET["confirmation-mail"]))
 | 
			
		||||
		echo "Le mail a bien été renvoyé.";
 | 
			
		||||
	else
 | 
			
		||||
		echo "Connexion réussie !";
 | 
			
		||||
if ($has_error)
 | 
			
		||||
	echo "<h2>Erreur : " . $error_message . "</h2>";
 | 
			
		||||
else {
 | 
			
		||||
	if (isset($recuperate_account))
 | 
			
		||||
		echo "<h2>Le mail de récupération de mot de passe a bien été envoyé.</h2>";
 | 
			
		||||
    elseif (isset($reset_password))
 | 
			
		||||
		echo "<h2>Le mot de passe a bien été changé. Vous pouvez désormais vous connecter.</h2>";
 | 
			
		||||
    elseif (isset($_GET["confirmation-mail"]))
 | 
			
		||||
		echo "<h2>Le mail a bien été renvoyé.</h2>";
 | 
			
		||||
	else if (isset($logging_in_user)) {
 | 
			
		||||
		echo "<h2>Connexion réussie !</h2>";
 | 
			
		||||
		require_once "footer.php";
 | 
			
		||||
	} else if (isset($_SESSION["user_id"])) {
 | 
			
		||||
		echo "<h2>Vous êtes déjà connecté.</h2>";
 | 
			
		||||
		require_once "footer.php";
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
else if (isset($_SESSION["user_id"])) { ?>
 | 
			
		||||
	<h2>Vous êtes déjà connecté !</h2>
 | 
			
		||||
if (isset($_GET["mdp_oublie"])) { ?>
 | 
			
		||||
    <form method="POST">
 | 
			
		||||
        <table style="width: 100%;">
 | 
			
		||||
            <tbody>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td style="width: 30%;">
 | 
			
		||||
                    <label for="email">E-mail associée au compte :</label>
 | 
			
		||||
                </td>
 | 
			
		||||
                <td style="width: 70%;">
 | 
			
		||||
                    <input style="width: 100%;" type="email" id="email" name="email"/>
 | 
			
		||||
                </td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td colspan="2">
 | 
			
		||||
                    <input style="width: 100%;" type="submit" name="forgotten_password"
 | 
			
		||||
                           value="Envoyer l'e-mail de récupération"/>
 | 
			
		||||
                </td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            </tbody>
 | 
			
		||||
        </table>
 | 
			
		||||
    </form>
 | 
			
		||||
<?php } elseif (isset($_GET["reset_password"])) {
 | 
			
		||||
	if ($reset_password->user != null) { ?>
 | 
			
		||||
        <form method="POST">
 | 
			
		||||
            <table style="width: 100%;">
 | 
			
		||||
                <tbody>
 | 
			
		||||
                <tr>
 | 
			
		||||
                    <td style="width: 30%;">
 | 
			
		||||
                        <label for="password">Nouveau mot de passe :</label>
 | 
			
		||||
                    </td>
 | 
			
		||||
                    <td style="width: 70%;">
 | 
			
		||||
                        <input style="width: 100%;" type="password" id="password" name="password"/>
 | 
			
		||||
                    </td>
 | 
			
		||||
                </tr>
 | 
			
		||||
                <tr>
 | 
			
		||||
                    <td style="width: 30%;">
 | 
			
		||||
                        <label for="confirm_password">Confirmer le mot de passe :</label>
 | 
			
		||||
                    </td>
 | 
			
		||||
                    <td style="width: 70%;">
 | 
			
		||||
                        <input style="width: 100%;" type="password" id="confirm_password" name="confirm_password"/>
 | 
			
		||||
                    </td>
 | 
			
		||||
                </tr>
 | 
			
		||||
                <tr>
 | 
			
		||||
                    <td colspan="2">
 | 
			
		||||
                        <input style="width: 100%;" type="submit" name="reset_password"
 | 
			
		||||
                               value="Changer le mot de passe"/>
 | 
			
		||||
                    </td>
 | 
			
		||||
                </tr>
 | 
			
		||||
                </tbody>
 | 
			
		||||
            </table>
 | 
			
		||||
        </form>
 | 
			
		||||
	<?php }
 | 
			
		||||
} elseif (isset($_GET["confirmation-mail"])) { ?>
 | 
			
		||||
<?php } else { ?>
 | 
			
		||||
 | 
			
		||||
	<?php if (isset($_GET["mdp_oublie"])) { ?>
 | 
			
		||||
		<form method="POST">
 | 
			
		||||
			<table style="width: 100%;">
 | 
			
		||||
				<tbody>
 | 
			
		||||
				<tr>
 | 
			
		||||
					<td style="width: 30%;">
 | 
			
		||||
						<label for="email">E-mail associée au compte :</label>
 | 
			
		||||
					</td>
 | 
			
		||||
					<td style="width: 70%;">
 | 
			
		||||
						<input style="width: 100%;" type="email" id="email" name="email" />
 | 
			
		||||
					</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				<tr>
 | 
			
		||||
					<td colspan="2">
 | 
			
		||||
						<input style="width: 100%;" type="submit" name="forgotten_password" value="Envoyer l'e-mail de récupération" />
 | 
			
		||||
					</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				</tbody>
 | 
			
		||||
			</table>
 | 
			
		||||
		</form>
 | 
			
		||||
	<?php } elseif (isset($_GET["reset_password"])) { ?>
 | 
			
		||||
		<form method="POST">
 | 
			
		||||
			<input type="hidden" name="token" value="<?= $_GET["token"] ?>" />
 | 
			
		||||
			<table style="width: 100%;">
 | 
			
		||||
				<tbody>
 | 
			
		||||
				<tr>
 | 
			
		||||
					<td style="width: 30%;">
 | 
			
		||||
						<label for="password">Nouveau mot de passe :</label>
 | 
			
		||||
					</td>
 | 
			
		||||
					<td style="width: 70%;">
 | 
			
		||||
						<input style="width: 100%;" type="password" id="password" name="password" />
 | 
			
		||||
					</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				<tr>
 | 
			
		||||
					<td style="width: 30%;">
 | 
			
		||||
						<label for="confirm_password">Confirmer le mot de passe :</label>
 | 
			
		||||
					</td>
 | 
			
		||||
					<td style="width: 70%;">
 | 
			
		||||
						<input style="width: 100%;" type="password" id="confirm_password" name="confirm_password" />
 | 
			
		||||
					</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				<tr>
 | 
			
		||||
					<td colspan="2">
 | 
			
		||||
						<input style="width: 100%;" type="submit" name="reset_password" value="Changer le mot de passe" />
 | 
			
		||||
					</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				</tbody>
 | 
			
		||||
			</table>
 | 
			
		||||
		</form>
 | 
			
		||||
	<?php } elseif (isset($_GET["confirmation-mail"])) { ?>
 | 
			
		||||
	<?php } else { ?>
 | 
			
		||||
		<form method="POST">
 | 
			
		||||
			<input type="hidden" name="submitted" value="true" />
 | 
			
		||||
			<table style="width: 100%;">
 | 
			
		||||
				<tr>
 | 
			
		||||
					<td style="width: 30%;"><label for="email">E-mail :</label></td>
 | 
			
		||||
					<td style="width: 70%;"><input  style="width: 100%;" type="email" id="email" name="email" value="<?php if (isset($email)) echo $email ?>" /></td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				<tr>
 | 
			
		||||
					<td><label for="password">Mot de passe :</label></td>
 | 
			
		||||
					<td><input style="width: 100%;" type="password" id="password" name="password" /></td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				<tr>
 | 
			
		||||
					<td colspan="2">
 | 
			
		||||
						<!--suppress HtmlUnknownTarget -->
 | 
			
		||||
						<a href="<?= $URL_BASE ?>/connexion/mdp_oublie">Mot de passe oublié ?</a>
 | 
			
		||||
					</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				<tr>
 | 
			
		||||
					<td colspan="2"><input style="width: 100%;" type="submit" value="Se connecter" /></td>
 | 
			
		||||
				</tr>
 | 
			
		||||
			</table>
 | 
			
		||||
		</form>
 | 
			
		||||
	<?php } ?>
 | 
			
		||||
    <form method="POST">
 | 
			
		||||
        <input type="hidden" name="submitted" value="true"/>
 | 
			
		||||
        <table style="width: 100%;">
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td style="width: 30%;"><label for="email">E-mail :</label></td>
 | 
			
		||||
                <td style="width: 70%;"><input style="width: 100%;" type="email" id="email" name="email"
 | 
			
		||||
                                               value="<?php if (isset($email)) echo $email ?>"/></td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td><label for="password">Mot de passe :</label></td>
 | 
			
		||||
                <td><input style="width: 100%;" type="password" id="password" name="password"/></td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td colspan="2">
 | 
			
		||||
                    <!--suppress HtmlUnknownTarget -->
 | 
			
		||||
                    <a href="<?= $URL_BASE ?>/connexion/mdp_oublie">Mot de passe oublié ?</a>
 | 
			
		||||
                </td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td colspan="2"><input style="width: 100%;" type="submit" value="Se connecter"/></td>
 | 
			
		||||
            </tr>
 | 
			
		||||
        </table>
 | 
			
		||||
    </form>
 | 
			
		||||
<?php } ?>
 | 
			
		||||
 | 
			
		||||
<?php require_once "footer.php" ?>
 | 
			
		||||
		Reference in New Issue
	
	Block a user