Örnek Görsel;

3
●130
<?php
// Soruları bir diziye tanımlıyoruz
$sorular = [
"Soru 1: Bu bir örnek sorudur.",
"Soru 2: PHP nedir?",
"Soru 3: PHP ile nasıl veri gönderilir?",
"Soru 4: Web geliştirme araçları nelerdir?",
"Soru 5: Son soru örneği."
];
// Geçerli soru indeksini kontrol ediyoruz (Varsayılan olarak ilk soru)
$soruIndeks = isset($_POST['soruIndeks']) ? (int)$_POST['soruIndeks'] : 0;
// 'Önceki Soru' butonuna basılmışsa indeks azaltılır
if (isset($_POST['onceki'])) {
$soruIndeks = max(0, $soruIndeks - 1); // 0'ın altına düşmesini engelliyoruz
}
// 'Sonraki Soru' butonuna basılmışsa indeks artırılır
if (isset($_POST['sonraki'])) {
$soruIndeks = min(count($sorular) - 1, $soruIndeks + 1); // Dizinin sınırını aşmıyoruz
}
// Geçerli soruyu alıyoruz
$gecerliSoru = $sorular[$soruIndeks];
?>
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Soru Sistemi</title>
</head>
<body>
<h1><?php echo $gecerliSoru; ?></h1>
<!-- Form ile butonlar -->
<form method="post">
<!-- Geçerli soru indeksini gizli bir alan ile gönderiyoruz -->
<input type="hidden" name="soruIndeks" value="<?php echo $soruIndeks; ?>">
<!-- Butonlar -->
<button type="submit" name="onceki" <?php if ($soruIndeks == 0) echo 'disabled'; ?>>Önceki Soruya Geç</button>
<button type="submit" name="sonraki" <?php if ($soruIndeks == count($sorular) - 1) echo 'disabled'; ?>>Sonraki Soruya Geç</button>
</form>
</body>
</html>