Mira a ver si esto te ayuda:
Código PHP:
<?
define ("pregunta_1","¿El cielo es azul?"); // definimos las preguntas
define ("respuesta_1","si"); // y las respuestas
define ("pregunta_2","¿Quien escribio Don Quijote De la Mancha?");
define ("respuesta_2","Cervantes");
$total_preguntas = 2; // numero total de preguntas
if (isset($_POST['enviado'])) {
for ($i=1;$i<$total_preguntas+1;$i++) {
if ($_POST["turespuesta_$i"] == constant("respuesta_".$i)) {
echo "Acerto la pregunta ".$i."!<br>";
} else {
echo "Ha fallado la pregunta ".$i."!<br>";
}
}
}
?>
<form method="POST">
<?
for ($i=1;$i<$total_preguntas+1;$i++) {
?>
Pregunta <? echo $i; ?> :<br>
<? echo constant("pregunta_".$i); ?>
<input type="text" name="<? echo "turespuesta_".$i; ?>"><br><br>
<?
}
?>
<input type="submit" name="enviado" value="Enviar">
</form>