From a0acb370f81adc87f21dbba4bea6953a714f098d Mon Sep 17 00:00:00 2001 From: ZHANG David <david.zhang@etu.univ-amu.fr> Date: Thu, 30 Jan 2025 20:22:01 +0000 Subject: [PATCH] Upload New File --- code/index.php | 134 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 code/index.php diff --git a/code/index.php b/code/index.php new file mode 100644 index 0000000..efc7fab --- /dev/null +++ b/code/index.php @@ -0,0 +1,134 @@ +<?php +ini_set('display_errors', 1); +ini_set('display_startup_errors', 1); +error_reporting(E_ALL); +include 'config.php'; +session_start(); + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $email = $_POST['email']; + $password = $_POST['password']; + + // Préparer la requête pour éviter les injections SQL + $stmt = $conn->prepare("SELECT id, first_name, last_name, email, role, specialty, password, status FROM User WHERE email = ?"); + $stmt->bind_param("s", $email); + $stmt->execute(); + $result = $stmt->get_result(); + $user = $result->fetch_assoc(); + + if ($user && password_verify($password, $user['password'])) { + // Stocker les informations utilisateur dans la session + $_SESSION['user'] = [ + 'id' => $user['id'], + 'first_name' => $user['first_name'], + 'last_name' => $user['last_name'], + 'email' => $user['email'], + 'role' => $user['role'], + 'specialty' => $user['specialty'], + 'status' => $user['status'] + ]; + header('Location: welcome.php'); + exit; + } else { + // Email ou mot de passe invalide + $error = "Invalid email or password."; + } + + $stmt->close(); +} +?> +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Welcome</title> + <link rel="stylesheet" href="style.css"> + <style> + body { + background-color: #f4f4f4; + margin: 0; + padding: 0; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + padding: 30px; + + } + .container { + text-align: center; + background: #fff; + padding: 20px; + border-radius: 8px; + box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); + max-width: 600px; + width: 90%; + } + h1 { + margin-top: 0; + color: #333; + } + p { + color: #555; + line-height: 1.6; + } + a { + text-decoration: none; + color: #007BFF; + margin: 10px; + } + a:hover { + text-decoration: underline; + } + img { + max-width: 100%; + height: auto; + border-radius: 8px; + margin-top: 20px; + } + </style> +</head> +<body> + + <div class="animated slideInLeft" id="square"> + <div class="animated bounceInUp" id="leftSquare"> + <div class="animated bounceInUp" id="circle"> + <img class="brand img-responsive" src="img/but.jpg" /> + + </div> + + <h2 id="title">Bienvenue sur Tutorat R&T</h2> + <h3 id="subtitle">Le savoir est la seule richesse qui s’accroît quand on la partage.</h3> + + </div> + + <div class="animated bounceInDown" id="rightSquare"> + <div id="container"> + <h1 class="signup">Connexion</h1> + + <form className="animated slideInLeft" method="post" action=""> + <?php if (isset($error)): ?> + <p class="error">⚠ <?= htmlspecialchars($error) ?></p> + <?php endif; ?> + + <input class="optin" type="mail" name="email" id="email" placeholder="email" required/> + <input class="optin" type="password" name="password" id="password"placeholder="Mot de passe" required/> + + <div></div> + <div id="button-container"> + <button class="animated infinite pulse button btn btn-info" onclick="window.location.href='register.html'">S'incrire</a></button> + <button class="animated infinite pulse button btn btn-info" type="submit">Se connecter</button> + </div> + <h3 id="footer">En continuant, vous acceptez nos <span id=« terms »>termes et conditions.</span></h3> + </form> + + </div> + + </div> + + +</body> + + +</html> -- GitLab