prepare("SELECT username, email FROM users WHERE username = ? OR email = ?"); $stmt->execute([$username, $email]); $existing_user = $stmt->fetch(); if ($existing_user) { if ($existing_user['username'] === $username) { $errors[] = 'Ce nom d\'utilisateur est déjà pris.'; } if ($existing_user['email'] === $email) { $errors[] = 'Cette adresse e-mail est déjà utilisée.'; } } else { // Hash password $hashed_password = password_hash($password, PASSWORD_DEFAULT); // Insert user $stmt = $pdo->prepare("INSERT INTO users (username, email, password) VALUES (?, ?, ?)"); $stmt->execute([$username, $email, $hashed_password]); // Get the new user's ID $user_id = $pdo->lastInsertId(); // Log the user in $_SESSION['user_id'] = $user_id; $_SESSION['username'] = $username; // Redirect to the main page header("Location: index.php"); exit(); } } catch (PDOException $e) { error_log("Registration Error: " . $e->getMessage()); $errors[] = 'Une erreur est survenue lors de l\'inscription. Veuillez réessayer.'; } } } ?> Inscription - Discord V2

Inscription