Ver Mensaje Individual
  #1 (permalink)  
Antiguo 29/04/2012, 13:53
neveuster
 
Fecha de Ingreso: febrero-2012
Mensajes: 163
Antigüedad: 12 años, 2 meses
Puntos: 0
Como añadir campo y capturarlo con post

Estimados amigos, he intentado mucho de las maneras que conozco, agregar dos o tres campos al ya creado y luego al enviar el formulario poder mostrarlos con el metodo post en un archivo llamado proceso.php, les ruego me ayuden a lograrlo,

por ahora solo puedo capturar el campo email.

muchas gracias, dejo el código hasta donde funciona... y les pido mucho su ayuda..

index.html
Código HTML:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Jquery Agregar campos</title>
<script type="text/javascript" src="jquery-1.6.4.min.js"></script>
<link href="style.css" rel="stylesheet" type="text/css" />

<script type="text/javascript"> 
emails=0; 
function agregar() { 
    emails=emails+1; 
    $("#campos").append('<li class="email'+emails+'"> <input type="text" name="email[]" size="25" /> &nbsp;&nbsp;<a href="#" onclick="javascript:borrar('+emails+');">Borrar</a> </li>'); 
} 
function borrar(cual) { 
    $("li.email"+cual).remove(); 
    return false; 
} 
</script> 
</head>
<body>

	<form name="frm_multiple" method="post" action="procesar.php">
    <ul id="emails">
    	<li>
        <input type="text" size="20" name="email[]" /><a href="javascript:agregar();">Agregar</a>
        </li>
		<li id="campos"><!-- aqui se crean los CAMPOS --></li>
    </ul>
	
    <p align="center"><input type="submit" name="Send" value="Send" /></p>
    </form>
 
</body>
</html> 
proceso.php
Código PHP:
<?php

$conexion 
mysql_connect("localhost""webmas_prueba""452348");
mysql_select_db("webmas_prueba"$conexion);


$emails=$_POST['email'];


for (
$i=0$i<=count($emails); $i++) 
{

    if(
$emails[$i] != "")
        {    
            echo 
$emails[$i];
        }
}
?>
Saludos.