delphi
<?php require_once('Connections/xxxxxx.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_registro, $registro); $query_datos = "SELECT * FROM clientes WHERE clientes.email like 'xxxxxxxxxxxxx'"; $datos = mysql_query($query_datos, $registro) or die(mysql_error()); $row_datos = mysql_fetch_assoc($datos); $totalRows_datos = mysql_num_rows($datos); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Documento sin título</title> <head> <script src="js/jquery-1.9.1.js"></script> <script src="js/jquery-ui.js"></script> <script> $(function() { $( "#tabs" ).tabs(); }); $(function(){ // Clona la fila oculta que tiene los campos base, y la agrega al final de la tabla $("#agregar").on('click', function(){ $("#tabla tbody tr:eq()").clone().append('<td class="eliminar"><input class="a" type="button" value="-"/></td>').appendTo("#tabla"); }); // Evento que selecciona la fila y la elimina $(document).on("click",".eliminar",function(){ var parent = $(this).parent(); $(parent).remove(); }); }); </script> </head> <body> <h1>Registro de Envios </h1> Reemplazar los datos de la nueva Linea<br> Datos enviados adicionalmente: <hr> <hr> <section class="formulario" id="formulario"><form action="test2.php" method="post"> <table borde="1" id="tabla"> <!-- Cabecera de la tabla --> <thead> <tr> <th></th> <th></th> <th></th> <th> </th> </tr> </thead> <!-- Cuerpo de la tabla con los campos --> <tbody> <!-- fila base para clonar y agregar al final --> <tr id="fila-base"> <td><input type="hidden" id="Nombre" name="Nombre[]" value="<?php echo $row_datos['Nombre']; ?>" /></td> <td><input type="hidden" id="cedula" name="cedula[]" value="<?php echo $row_datos['cedula']; ?>" /></td> <td><input type="hidden" id="email" name="email[]" value="<?php echo $row_datos['email']; ?>" /></td> <td><input id="empresa" name="empresa[]" placeholder=" Empresa" /></td> <td><input id="tracking" name="tracking[]" placeholder=" Codigo" /></td> <td><input type="hidden" id="estatus" name="estatus[]" value="En Transito" /></td> <td><input type="hidden" id="lugar" name="lugar[]" value="No Entregado" /></td> <td><input type="hidden" id="fecha_registro" name="fecha_registro[]" value="<?php echo date("d-m-Y H:i:s"); ?>"/></td> <td><input type="hidden" id="fecha_estatus" name="fecha_estatus[]" value="<?php echo date("d-m-Y H:i:s"); ?>"/></td> </td> </tr> <!-- fin de código: fila base --> </tbody> </table> <!-- Botón para agregar filas --> <input type="submit"> <input type="button" class="a" id="agregar" value="+" /> </form></section> </body> </html> <?php mysql_free_result($datos); ?>
al enviar los datos estos llegan a la siguiente pagina de esta manera
delphi
Array ( [Nombre] => Array ( [0] => carlos quintero [1] => carlos quintero [2] => carlos quintero [3] => carlos quintero ) [cedula] => Array ( [0] => 14624982 [1] => 14624982 [2] => 14624982 [3] => 14624982 ) [email] => Array ( [0] => xxxxxxxxxxxxxx [1] =>xxxxxxxxxxxxxxxx [2] => xxxxxxxxxxxxxxxxxx [3] => xxxxxxxxxxxxx ) [empresa] => Array ( [0] => Carlos [1] => Carlos [2] => Manuel [3] => Marle ) [tracking] => Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 ) [estatus] => Array ( [0] => En Transito [1] => En Transito [2] => En Transito [3] => En Transito ) [lugar] => Array ( [0] => No Entregado [1] => No Entregado [2] => No Entregado [3] => No Entregado ) [fecha_registro] => Array ( [0] => 11-01-2015 17:18:53 [1] => 11-01-2015 17:18:53 [2] => 11-01-2015 17:18:53 [3] => 11-01-2015 17:18:53 ) [fecha_estatus] => Array ( [0] => 11-01-2015 17:18:53 [1] => 11-01-2015 17:18:53 [2] => 11-01-2015 17:18:53 [3] => 11-01-2015 17:18:53 ) )
el problema es que no los guarda en la base de datos, el codigo que utilizo es este, no se si es la conexion a la base o que es lo que me falla.
delphi
<?php $nombre = $_POST['Nombre']; $cedula = $_POST['cedula']; $email = $_POST['email']; $empresa = $_POST['empresa']; $tracking = $_POST['tracking']; $estatus = $_POST['estatus']; $lugar = $_POST['lugar']; $fecha_registro = $_POST['fecha_registro']; $fecha_estatus = $_POST['fecha_estatus']; $host="localhost"; $user="xxxxxxxxxxxxxx"; $pass="xxxxxxxxxxxxxx"; $dbname="xxxxxxxxxxxxx"; //Abrimos la conexión $conexion = mysqli_connect($host,$user,$pass); //Seleccionamos la base de datos con la que trabajar mysqli_select_db($dbname,$conexion); $i = 0; foreach($nombre as $nonmbre) { $consulta = "INSERT INTO tracking ('id','Nombre', 'cedula', 'email', 'empresa', 'tracking', 'estatus', 'lugar', 'fecha_registro', 'fecha_estatus') VALUES ('".NULL."', '".$nombre[$i]."' , '".$cedula[$i]."' , '".$email[$i]."' , '".$empresa[$i]."' , '".$tracking[$i]."' , '".$estatus[$i]."' , '".$lugar[$i]."' , '".$fecha_registro[$i]."', '".$fecha_estatus[$i]."')"; $i++; //$resultado = mysql_query($consulta, $conexion); } echo "¡Gracias! Hemos recibido sus datos.\n"; echo "<pre>"; print_r($_POST); echo "</pre>"; ?>
el asunto es que pasa directamente a este mensaje
delphi
echo "¡Gracias! Hemos recibido sus datos.\n";
sin guardar nada.
Gracias