Story 5.1: formulaire contact HTML5

This commit is contained in:
2026-02-04 20:41:37 +01:00
parent 325625f664
commit 70580f2d96
5 changed files with 296 additions and 51 deletions

View File

@@ -180,4 +180,26 @@ function getTestimonialByProject(string $projectSlug): ?array
}
}
return null;
}
/**
* CSRF token helpers
*/
function generateCsrfToken(): string
{
if (session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
if (empty($_SESSION['csrf_token'])) {
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
}
return $_SESSION['csrf_token'];
}
function verifyCsrfToken(?string $token): bool
{
if (session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
return !empty($token) && !empty($_SESSION['csrf_token']) && hash_equals($_SESSION['csrf_token'], $token);
}