Ver Mensaje Individual
  #4 (permalink)  
Antiguo 21/03/2006, 16:15
Cubatron
 
Fecha de Ingreso: diciembre-2005
Mensajes: 165
Antigüedad: 18 años, 4 meses
Puntos: 4
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); ?>&nbsp;
<input type="text" name="<? echo "turespuesta_".$i?>"><br><br>
<?
}
?>
<input type="submit" name="enviado" value="Enviar">
</form>