<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Kode Verifikation</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin: 50px;
}
input {
margin: 10px;
padding: 10px;
font-size: 16px;
}
button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
}
.message {
margin-top: 20px;
font-size: 18px;
}
</style>
</head>
<body>
<h1>Kode Verifikation</h1>
<form method="POST" action="">
<input type="text" name="code" placeholder="Indtast din kode" required>
<button type="submit">Verificer</button>
</form>
<div class="message">
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$code = $_POST['code'];
// Databaseforbindelse
$servername = "localhost";
$username = "root"; // Skift til din databasebrugers navn
$password = ""; // Skift til din databases adgangskode
$dbname = "codes_database"; // Skift til dit databasenavn
// Opret forbindelse
$conn = new mysqli($servername, $username, $password, $dbname);
// Tjek forbindelsen
if ($conn->connect_error) {
die("Forbindelse fejlede: " . $conn->connect_error);
}
// Tjek koden i databasen
$stmt = $conn->prepare("SELECT * FROM codes WHERE code = ?");
$stmt->bind_param("s", $code);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
echo "<p style='color: green;'>Koden er korrekt!</p>";
} else {
echo "<p style='color: red;'>Koden er forkert!</p>";
}
$stmt->close();
$conn->close();
}
?>
</div>
</body>
</html>