3v4l.org

run code in 500+ PHP versions simultaneously
<?php session_start(); $erreur = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { $utilisateur = $_POST["username"]; $motdepasse = $_POST["password"]; // Identifiants de démonstration if ($utilisateur == "admin" && $motdepasse == "1234") { $_SESSION["username"] = $utilisateur; header("Location: bienvenue.php"); exit(); } else { $erreur = "Nom d'utilisateur ou mot de passe incorrect."; } } ?> <!DOCTYPE html> <html lang="fr"> <head> <meta charset="UTF-8"> <title>Connexion</title> </head> <body> <h2>Connexion</h2> <?php if (!empty($erreur)) : ?> <p style="color:red;"><?php echo $erreur; ?></p> <?php endif; ?> <form method="POST"> <label>Nom d'utilisateur :</label><br> <input type="text" name="username" required><br><br> <label>Mot de passe :</label><br> <input type="password" name="password" required><br><br> <button type="submit">Se connecter</button> </form> </body> </html>
Output for 8.2.31, 8.3.0 - 8.3.31, 8.4.1 - 8.4.21, 8.5.0 - 8.5.6
Warning: Undefined array key "REQUEST_METHOD" in /in/N1pdU on line 6 <!DOCTYPE html> <html lang="fr"> <head> <meta charset="UTF-8"> <title>Connexion</title> </head> <body> <h2>Connexion</h2> <form method="POST"> <label>Nom d'utilisateur :</label><br> <input type="text" name="username" required><br><br> <label>Mot de passe :</label><br> <input type="password" name="password" required><br><br> <button type="submit">Se connecter</button> </form> </body> </html>

preferences:
45.8 ms | 770 KiB | 4 Q