<?php

$alumno=$_POST['matricula'];
@$materias=$_POST['materias'];

$total= sizeof($materias);
if ($total == '0')
{
	?>
        <script>
			location.href="main.php?a=4742&Alumno=<?php echo $alumno;?>&error=1";
	    </script>
          <?php
}
else
{
	include ("conexion.php");
	
	for($x=0; $x < sizeof($materias); $x++)
	{
		$cons1="SELECT * FROM asignacionmaterias WHERE idAlumno='$alumno' and idMateria='$materias[$x]'";
		$res1=mysql_query($cons1,$conex) or die ("No se realizó la insercion de materias");
		$hay=mysql_fetch_row($res1);
		
		if ($hay == 0)
		{
			//INSERCION EN LA BASE DE DATOS
			$cons5="INSERT INTO asignacionmaterias (idAlumno,idMateria) VALUES ('$alumno','$materias[$x]')";
			$res5=mysql_query($cons5,$conex) or die ("No se realizó la insercion de materias");
		}
		else
		{
		}
	}
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>UCA :.</title>
<link href="ucaestilos.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
	background-color: #CCCCCC;
}
-->
</style></head>

<body>
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td><img src="img/top02.jpg" width="800" height="100" /></td>
  </tr>
  <tr>
    <td><p>&nbsp;</p>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><div align="center"><img src="img/confproc.jpg"  /></div></td>
      </tr>
    </table>
      <br />
      <table width="200" border="0" align="center" cellspacing="10">
        <tr>
          <td width="97"><form id="form1" name="form1" method="post" action="main.php?a=474">
              <div align="center">
                <p>
                  <input name="Submit" type="submit" class="boton2" value="Regresar a alumnos" />
                </p>
              </div>
          </form></td>
          <td width="93"><form id="form1" name="form1" method="post" action="main.php">
              <div align="center">
                <p>
                  <input name="Submit" type="submit" class="boton2" value="Volver a inicio" />
                </p>
              </div>
          </form></td>
        </tr>
      </table>
      <p>&nbsp;</p>
    <table width="100%" border="0">
         <tr>
        <td height="26" style="background-color:#0D3356;">
        <div align="center" id="noimprimible">
          <table width="99%" border="0" align="center" cellpadding="2" cellspacing="0">
            <tr>
              <td align="center" class="style8">Desarrollado para la Universidad Cuauht&eacute;moc por <a href="http://www.upweb.mx" target="_blank"><img src="img/webmaster.svg" style="height:16px; vertical-align:bottom;"></a></td>
            </tr>
          </table>
        </div></td>
        </tr>
      </table></td></tr>
</table>
</body>
</html>
