<?php
 session_start();
 require "conecta.php";
 $usu=$_SESSION['nick'];
 $numero=sprintf("%07d",$_POST['hdcot']);
 $sqlb="select * from m02009 where llave='$numero';";
 $resb=mysql_query($sqlb,$con) or die(mysql_error());
 while ($filab=mysql_fetch_row($resb)){
  $cod=$filab[1];
  $gl=$filab[2];
  $pre=$filab[3];
  $cant=$filab[4];
  $tot=$filab[5];
  $sqlgraba="insert into m02004 values ('$usu','$cod','','$gl','0','$cant','$pre','$tot');";
  $rsgraba=mysql_query($sqlgraba,$con) or die(mysql_error());
  header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/carro.php" );
 }
?>