<?php

$id=$_POST['producto'];
@$paquetes=$_POST['paquetes'];
@$cantidad=$_POST['cantidad'];

$total= sizeof($paquetes);
if ($total == '0')
{
	?>
        <script>
			location.href="main.php?a=201&idProd=<?php echo $id;?>&error=1";
	    </script>
          <?php
}
else
{
	include ("conexion.php");
	
	for($x=0; $x < sizeof($paquetes); $x++)
	{
		$cons1="SELECT * FROM contenido_paquete WHERE clave='$id' and idPaquete='$paquetes[$x]'";
		$res1=mysql_query($cons1,$conex) or die ("No se realiz� cons1");
		$hay=mysql_fetch_row($res1);
		
		if ($hay == 0)
		{
			//INSERCION EN LA BASE DE DATOS
			$cons5="INSERT INTO contenido_paquete (clave,idPaquete,cantidad) VALUES ('$id','$paquetes[$x]','$cantidad[$x]')";
			$res5=mysql_query($cons5,$conex) or die ("No se realiz� la insercion de contenido_paquete");
		}
	}
}

?>
<!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></title>
<link href="ucaestilos.css" rel="stylesheet" type="text/css" />
</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=2">
              <div align="center">
                <p>
                  <input name="Submit" type="submit" class="boton2" value="Regresar a productos" />
                </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>
