-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
57 lines (49 loc) · 2 KB
/
index.php
File metadata and controls
57 lines (49 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
session_start();
require __DIR__ . '/vendor/autoload.php';
use SecurePHP\CSRF;
$message = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$token = $_POST['_csrf_token'] ?? '';
$name = htmlspecialchars($_POST['name'] ?? '', ENT_QUOTES, 'UTF-8');
if (CSRF::verifyToken($token)) {
$message = '<div class="alert alert-success mt-3">✅ CSRF valide ! Bonjour <b>' . $name . '</b>.</div>';
} else {
$message = '<div class="alert alert-danger mt-3">❌ CSRF Token invalide !</div>';
}
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SecurePHP - Test CSRF Protection</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light d-flex align-items-center justify-content-center" style="height: 100vh;">
<div class="container">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card shadow-lg border-0 rounded-4">
<div class="card-body p-4">
<h3 class="text-center mb-4 text-primary">🔒 SecurePHP CSRF Test</h3>
<form method="POST">
<div class="mb-3">
<label for="name" class="form-label">Votre nom</label>
<input type="text" class="form-control" id="name" name="name" required placeholder="Entrez votre nom">
</div>
<?= \SecurePHP\CSRF::inputField(); ?>
<button type="submit" class="btn btn-primary w-100 rounded-3">Tester</button>
</form>
<?= $message ?>
</div>
<div class="card-footer text-center text-muted small">
SecurePHP v1.0 — © <?= date('Y') ?> Fordi Malanda
</div>
</div>
</div>
</div>
</div>
</body>
</html>