El problema es que cuando pongo la respuesta correcta me la pone como si la tubiera mas les paso el codigo y las tablas aver si alguien me puede ayudar ya intente todo lo ke puede :(
 
index.php
 
<body>
<form method="post" action="examen.php">
 <h3>Ingresar al sistema de examenes en linea</h3>
  Matricula: 
  <label>
  <input type="text" name="user" />
  </label>
  <p>Password: 
    <label>
    <input type="password" name="pss" />
    </label>
  </p>
  <p>
    <label>
    <input type="submit" value="Entrar" />
    </label>
</p>
</form>
</body>
 
examen.php
 
<?
  $user = (isset($_POST['user'])?$_POST['user']:NULL);
  $pass = (isset($_POST['pss'])?$_POST['pss']:NULL);
  $numPregs = 10; // asegurarse q la bd tenga >=10 preguntas
  $conexion = mysql_connect("localhost","root","");
  if(!$conexion){
    echo "<p>Error: No se puede conectar al servidor</p>\n";
  }
  else{
    $bd = mysql_select_db("examenes",$conexion);
	 if(!$bd){
	   echo "<p>Error: No se pudo seleccionar la bd</p>\n";
	 }
	 else if($user==null || $pass==null){
	   echo "<p>Error: Datos de login nulos<br>\n";
	   echo "<a href=\"Index.php\"> Regresar al homie ese</a> </p>\n";
	 }
	 else{
	   $nombre = mysql_query("select nombre from usuarios where matricula='$user' and password='$pass'",$conexion);
	   $presento = mysql_query("select presento from usuarios where matricula='$user' and password='$pass'",$conexion);
	   if(mysql_num_rows($nombre)<=0){
	     echo "<p>Autentificacion incorrecta<br>\n";
	     echo "<a href=\"Index.php\"> Regresar al homie ese</a> </p>\n";
	   }
	   else if(mysql_result($presento,0,'presento')==1){
	     echo "<p>El alumno ".mysql_result($nombre,0,'nombre')." matricula $user ya presento este examen<br>\n";
	     echo "<a href=\"Index.php\"> Regresar al homie ese</a> </p>\n";
	   }
	   else{
             echo "<h2> Examen de conocimientos de variedades</h2>\n";
             echo "<p>Bienvenido alumno ".mysql_result($nombre,0,'nombre')."</p>\n";
	     // seleccionar las preguntas aleatoriamente
	     $pregsInBD = mysql_query("select count(idp) as 'num' from preguntas",$conexion);
	     $pregsExistentes = mysql_result($pregsInBD,0,'num');
	     for($r=0;$r<$numPregs;$r++) $vector[$r]=0;
	     for($r=0;$r<$numPregs;$r++){
               $alea=rand(1,$pregsExistentes);
               $bandera=true;
               for($f=0;$f<$r;$f++)
                 if($vector[$f]==$alea){
                   $bandera=false;
                   break;
                 }
               if(!$bandera){ $r--; continue; }
               $vector[$r]=$alea;
             }
             // cargar las preguntas
             echo '<form action="califica.php" method="post">'."\n";
             for($r=0;$r<$numPregs;$r++){
               $pregActu = mysql_query("select preguntas from preguntas where idp='$vector[$r]'",$conexion);
               $txtPregActu = mysql_result($pregActu,0,'preguntas');
               $tpPreg = mysql_query("select tipo from preguntas where idp='$vector[$r]'",$conexion);
               $tipoPreg = mysql_result($tpPreg,0,'tipo');
               echo "<p>\n";
               echo "".($r+1).") ".$txtPregActu;
               if($tipoPreg==1){ // abierta
                 echo ' <input type="text" name="'.$r.'">'."\n";
                 echo ' <input type="hidden" name="preg'.($r+1).'" value="'.$vector[$r].'">'."\n";
               }
               else{ // multiopcion
                 $consOps = mysql_query("select idr from corresponde where idp='$vector[$r]'",$conexion);
                 $numResp = mysql_num_rows($consOps);
                 echo "\n<br>";
                 echo ' <input type="hidden" name="preg'.($r+1).'" value="'.$vector[$r].'">'."\n";
                 for($hui=0;$hui<$numResp;$hui++){
                   $consResp = mysql_query("select respuesta from respuestas where idr='".mysql_result($consOps,$hui,'idr')."'",$cone  xion);
                   $valor= mysql_result($consResp,0,'respuesta');
                   echo '<input type="radio" name="'.$r.'" value="'.$valor.'">'.$valor."<br>\n";
                 }
               }
               echo "</p>\n";
             }
             echo '<input type="hidden" name="mat" value="'.$user.'">'."\n";
             echo '<input type="submit" value="Calificar">'."\n";
             echo '</form>'."\n";
             mysql_Close($conexion);
          }
      }
  }
?>
 
califica.php
 
<?
  // $numPregs = 10; // asegurarse q la bd tenga >=10 preguntas
  // diseño estatico para solo revisar diez preguntas
  $preg[0] = (isset($_POST['preg1'])?$_POST['preg1']:NULL);
  $preg[] = (isset($_POST['preg2'])?$_POST['preg2']:NULL);
  $preg[] = (isset($_POST['preg3'])?$_POST['preg3']:NULL);
  $preg[] = (isset($_POST['preg4'])?$_POST['preg4']:NULL);
  $preg[] = (isset($_POST['preg5'])?$_POST['preg5']:NULL);
  $preg[] = (isset($_POST['preg6'])?$_POST['preg6']:NULL);
  $preg[] = (isset($_POST['preg7'])?$_POST['preg7']:NULL);
  $preg[] = (isset($_POST['preg8'])?$_POST['preg8']:NULL);
  $preg[] = (isset($_POST['preg9'])?$_POST['preg9']:NULL);
  $preg[] = (isset($_POST['preg10'])?$_POST['preg10']:NULL);
 
  $respDada[0] = (isset($_POST['0'])?$_POST['0']:NULL);
  $respDada[] = (isset($_POST['1'])?$_POST['1']:NULL);
  $respDada[] = (isset($_POST['2'])?$_POST['2']:NULL);
  $respDada[] = (isset($_POST['3'])?$_POST['3']:NULL);
  $respDada[] = (isset($_POST['4'])?$_POST['4']:NULL);
  $respDada[] = (isset($_POST['5'])?$_POST['5']:NULL);
  $respDada[] = (isset($_POST['6'])?$_POST['6']:NULL);
  $respDada[] = (isset($_POST['7'])?$_POST['7']:NULL);
  $respDada[] = (isset($_POST['8'])?$_POST['8']:NULL);
  $respDada[] = (isset($_POST['9'])?$_POST['9']:NULL);
 
  $matricula = (isset($_POST['mat'])?$_POST['mat']:NULL);
  if(!$preg||!$respDada||!$matricula){
    echo "<p>Acceso invalido</p>";
  }
  else{
    $conexion = mysql_connect("localhost","root","");
    if(!$conexion){
      echo "<p>Error: No se puede conectar al servidor<br>\n";
      echo "<a href=\"Index.php\"> Regresar al homie ese</a> </p>\n";
    }
    else{
      $bd = mysql_select_db("examenes",$conexion);
      if(!$bd){
        echo "<p>Error: No se pudo seleccionar la bd<br>\n";
        echo "<a href=\"Index.php\"> Regresar al homie ese</a> </p>\n";
      }
      else{
        $calif=0;
        $consulta = mysql_query("select nombre from usuarios where matricula='$matricula'",$conexion);
        echo "<h2> Calificacion </h2>\n";
        echo "<p> Alumno ".mysql_result($consulta,0,'nombre')." matricula $matricula</p>\n";
        for($cju=0;$cju<sizeof($preg);$cju++){
          $consulta = mysql_query("select idr from corresponde where idp='$preg[$cju] and sipi=1'",$conexion);
          $idres = mysql_result($consulta,0,'idr');
          $consulta = mysql_query("select respuesta from respuestas where idr='$idres'",$conexion);
          $respuestidirijilla = mysql_result($consulta,0,'respuesta');
          if($respDada[$cju]==$respuestidirijilla) $calif+=1;
        }
        mysql_query("update usuarios set calif='$calif', presento=1 where matricula='$matricula'",$conexion);
        mysql_Close($conexion);
        echo "<p>Ha obtenido una calificacion ".($calif>=7?"aprobatoria":"reprobatoria")." de $calif</p>";
        echo "<p><a href=\"Index.php\"> Regresar al homie ese</a> </p>\n";
      }
    }
  }
?>
 
Ayuda Por favor !!! 
   
 
 Problema con código examen con php Mysql
 Problema con código examen con php Mysql 



