hola buenas a todos tengo un formulario y cuando guardo los datos en la base datos me los guarda todos pero lo del input dinamico me los guarda en blanco
agradezco su ayuda...gracias
Código codigo:
Ver original<?php
include_once "../conectar/conexion.php";
include_once "../inicio.php";
$idS = $_GET['Sede'];
$idE = $_GET['Escuela'];
$idN = $_GET['Nombre'];
$codigoS="";
$codigoE="";
$Nombre="";
$combobit_pn="";
$buscarp = "SELECT MAX(p.Codigo),p.Nombre,e.Nombre AS Escuela,s.Nombre AS Sede FROM programas p,escuelas e,sedes s WHERE p.Nombre = '".$_GET['Nombre']."' AND p.Escuela =".$_GET['Escuela']." AND p.Sede = ".$_GET['Sede']."";
$resultP = mysql_query($buscarp) or die(mysql_error());
while($row1=mysql_fetch_row($resultP)){
$combobit_pn .=$row1[1];
$combobit_pn1 =$row1[0];
$codigoE .=$row1[2];
$codigoS .=$row1[3];
}
?>
<html lang="es">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Crear Guias</title>
<link rel="stylesheet" href="/MatrizCensa/estilos/formulario2.css">
<script language="JavaScript" src="/MatrizCensa/calendario/javascripts.js"></script>
<link rel="STYLESHEET" type="text/css" href="/MatrizCensa/calendario/estilo.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="/MatrizCensa/js/jquery-1.3.2.min.js"></script>
<link rel="stylesheet" href="/MatrizCensa/estilos/estilos.css">
<script type="text/javascript">
function crearCampos(cantidad){
var div = document.getElementById("Guia");
while(div.firstChild)div.removeChild(div.firstChild); // remover elementos;
for(var i = 1, cantidad = Number(cantidad); i <= cantidad; i++){
var salto = document.createElement("P");
var input = document.createElement("input");
var text = document.createTextNode("Guia " + i + ": ");
input.setAttribute("name", "nombre1[]");
input.setAttribute("size", "12");
input.className = "input";
salto.appendChild(text);
salto.appendChild(input);
div.appendChild(salto);
}
}
</script>
</head>
<body>
<form name = "fcalen" enctype=multipart/form-data" action="" method="post" class="registro" >
<table>
<div><tr><td>Sede :<input type="text" name="seden" value ="<?php echo $codigoS; ?>" disabled>
<input type="hidden" name="sede" value ="<?php echo $idS; ?>" ></div></td>
<div><td>Escuela :<input type="text" name="escuelan" value ="<?php echo $codigoE; ?>" disabled>
<input type="hidden" name="escuela" value ="<?php echo $idE; ?>" ></div></td></tr>
<div><tr><td>Programa :<input type="text" name="programan" value ="<?php echo $combobit_pn; ?>" disabled>
<input type="hidden" name="programa" value ="<?php echo $combobit_pn1; ?>" ></div></td></tr>
<tr><td>Numeros de Guias:<input type="text" name="cantidad" id="cantidad" value="" onkeyup="crearCampos(this.value);" ></div></td></tr>
</table>
<input type="submit" id="boton" name="crear" value="Crear" onclick="crearCampos(this.form.cantidad.value);" ><div id="Guia"></div>
</form>
</body>
</html>
<?php
if(isset($_POST['crear'])){
for($i = 0; $i < count($_POST['nombre1']); $i++) { // Tomas el valor del campo
//$variable = $_POST['nombre1'][$i]; // Aqui lo verificas e insertas en la base de datos
$guardar = "INSERT INTO guias(Nombre, Programa, Escuela, Sede, Numero_guia) VALUES ('".($_POST['nombre1'][$i])."','".$_POST['programa']."','".$_POST['escuela']."','".$_POST['sede']."','".$_POST['cantidad']."')";
$result = mysql_query($guardar) or die(mysql_error());
}
$date = date_default_timezone_get();
$crearLog = "INSERT INTO log_usr(Usuario, Fecha, Accion) VALUES ('".$_SESSION['userid']."','".$date."','Creacion de guias.')";
$result = mysql_query($crearLog) or die(mysql_error());
/*header("location:/MatrizCensa/");*/
}elseif(isset($_POST['cancelar'])){
header("location:/MatrizCensa/inicio.php");
}
?>