Foros del Web » Creando para Internet » Diseño web »

Como hago el send.php para un array de elementos?

Estas en el tema de Como hago el send.php para un array de elementos? en el foro de Diseño web en Foros del Web. Estoy intentando terminar el archivo send.php de un formulario. Pero a su vez es de una página que tiene un número indefinido de campos dependiendo ...
  #1 (permalink)  
Antiguo 22/06/2011, 15:04
 
Fecha de Ingreso: junio-2011
Mensajes: 1
Antigüedad: 12 años, 10 meses
Puntos: 0
Como hago el send.php para un array de elementos?

Estoy intentando terminar el archivo send.php de un formulario. Pero a su vez es de una página que tiene un número indefinido de campos dependiendo de un carrito de compra.... ¿Cómo se nombran?

Os pongo el formulario.html
<html>
<head>
<title>Formulario</title>
<style type="text/css">
.body {
font-family: Times New Roman;
font-size: 10pt;
font-style: normal;
font-weight: normal;
font-variant: normal;
color: #000000;
}

.td {
font-family: Times New Roman;
font-size: 10pt;
font-style: normal;
line-height: normal;
font-weight: normal;
font-variant: normal;
color: #000000;
}


</style>
<SCRIPT LANGUAGE="JavaScript">
<!--
function Enviar(form) {
for (i = 0; i < form.elements.length; i++) {
if (form.elements[i].type == "text" && form.elements[i].value == "") {
alert("Por favor complete todos los campos del formulario"); form.elements[i].focus();
return false; }
}
form.submit();
}
// -->
</SCRIPT>
</head>
<body bgcolor="#FFFFFF" link="#400080" vlink="#800080" class="body">
<SCRIPT LANGUAGE="JavaScript">

function alterError(value) {
if (value<=0.99) {
newPounds = '0';
} else {
newPounds = parseInt(value);
}
newPence = parseInt((value+.0008 - newPounds)* 100);
if (eval(newPence) <= 9) newPence='0'+newPence;
newString = newPounds + '.' + newPence;
return (newString);
}

function showItems() {
index = document.cookie.indexOf("TheBasket");
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1) {
countend = document.cookie.length;
}
fulllist = document.cookie.substring(countbegin, countend);
totprice = 0;

itemlist = 0;
for (var i = 0; i <= fulllist.length; i++) {
if (fulllist.substring(i,i+1) == '[') {
itemstart = i+1;
} else if (fulllist.substring(i,i+1) == ']') {
itemend = i;
thequantity = fulllist.substring(itemstart, itemend);
itemtotal = 0;
itemtotal = (eval(theprice*thequantity));
temptotal = itemtotal * 100;
var tax = itemtotal / 100 * (0 - 0);
tax = Math.floor(tax * 100)/100
totprice = totprice + itemtotal + tax;
itemlist=itemlist+1;
document.writeln('<INPUT NAME="Producto'+itemlist+'" VALUE="'+theitem+'" SIZE="40">');
document.writeln('<INPUT NAME="Cantidad'+itemlist+'" VALUE="'+thequantity+'" SIZE="40">')
document.writeln('<INPUT NAME="ProductoTotal'+itemlist+'" VALUE="'+alterError(itemtotal)+'" SIZE="40">');
} else if (fulllist.substring(i,i+1) == ',') {
theitem = fulllist.substring(itemstart, i);
itemstart = i+1;
} else if (fulllist.substring(i,i+1) == '#') {
theprice = fulllist.substring(itemstart, i);
itemstart = i+1;
}
}

document.writeln('<INPUT TYPE="hidden" NAME="Total" VALUE="'+alterError(totprice)+'" SIZE="40">');

}
function ShowItems(){}
function Total() {
document.writeln(alterError(totprice));
}

</SCRIPT>
<center>
<table border="0" cellpadding="0" cellspacing="0" width="640" class="body">
<tr>
<td width="50%"><big><big>Formulario</big></big></td>
<td width="50%" align="right">[ <a href="carrito.htm">Carrito de Compra</a> | <a href="estado.htm">Estado</a> | Formulario ]</td>
</tr>
<tr>
<td width="100%" colspan="2">
<hr size="1" color="#000000">
</td>
</tr>
<tr>
<td width="100%" colspan="2"></td>
</tr>
</table>

<FORM method="post" action="send.php" target="_top">

<!--<input type=hidden name="recipient" value="mi correo">
<input type=hidden name="subject" value="">
<input type=hidden name="redirect" value="http://www.jjj.es">
<input type=hidden name="env_report" value="REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT">-->
<table cols="2" width="370" class="body">
<td width="130"></td>
<td width="270">
</td>
</tr>
<tr><td>Nombre</td><td><input type="text" name="nombre" size=34></td></tr>
<tr><td>Apellido</td><td><input type="text" name="apellido" size=34></td></tr>
<tr><td>Domicilio</td><td><input type="text" name="domicilio" size=34></td></tr>
<tr><td>Ciudad</td><td><input type="text" name="ciudad" size=34></td></tr>
<tr><td>Provincia</td><td><input type="text" name="provincia" size=34></td></tr>
<tr><td>Código Postal</td><td><input type="text" name="cp" size=34></td></tr>
<tr><td>País</td><td><input type="text" name="pais" size=34></td></tr>
<tr><td>E-mail</td><td><input type="text" name="email" size=34></td></tr>
<tr><td>Teléfono</td><td><input type="text" name="telefono" size=34></td></tr>
<tr><td>Fax</td><td><input type="text" name="fax" size=34></td></tr>

<SCRIPT LANGUAGE="JavaScript">
showItems();
</SCRIPT>
<tr>
<td>Total:</td>
<td>&euro;
<SCRIPT LANGUAGE="JavaScript">Total()</SCRIPT></td>
</tr>

<tr>
Comentarios: <br /><textarea class="texto" name="comentarios" rows="4" cols="60"></textarea> </tr>
</td>
<td>
<input type="button" value="Enviar" onClick="return Enviar(this.form)">
</td><td><input type="reset" value="Restablecer">
</td>
</tr>
</table>
</form>

</center>
</body>
</html>[/
COLOR]
________________________________

LA función showItems() es la que va poniendo en el formulario un numero x de productos y luego.....????? Cómo los paso si no sé cuantos son al send.php????

______________

Codigo de mi send.php
<?php

$nombre = $_POST['nombre'];
$apellido = $_POST['apellido'];
$domicilio = $_POST['domicilio'];
$ciudad = $_POST['ciudad'];
$provincia = $_POST['provincia'];
$cp = $_POST['cp'];
$pais = $_POST['pais'];
$email=$_POST['email'];
$fax = $_POST['fax'];
$header = 'From: ' . $email . "\r\n";
$header .= "X-Mailer: PHP/" . phpversion() . " \r\n";
$header .= "Mime-Version: 1.0 \r\n";
$header .= "Content-Type: text/plain";

$mensaje = "Este mensaje fue enviado por " . $nombre " \r\n";
$mensaje .= "Apellido: " . $apellido . " \r\n";
$mensaje .= "Domicilio: " . $domicilio . " \r\n";
$mensaje .= "Ciudad: " . $ciudad . " \r\n";
$mensaje .= "Provincia: " . $provincia . " \r\n";
$mensaje .= "Codigo postal: " . $cp . " \r\n";
$mensaje .= "Su e-mail es: " . $email . " \r\n";
$mensaje .= "Su telefono es: " . $telefono . " \r\n";
$mensaje .= "Su fax es: " . $fax . " \r\n";
$mensaje .= "Enviado el " . date('d/m/Y', time());
$mensaje .= "Ha comentado lo siguiente: " . $comentarios . " \r\n";



$para = 'micorreo';
$asunto = 'Pedido';

mail($para, $asunto, utf8_decode($mensaje), $header);
echo 'EL MENSAJE SE ENVIO CORRECTAMENTE - AGUARDE QUE SERA REDIRECCIONADO A LA PAGINA PRINCIPAL - www.jjj.es';
header('refresh:3; url=index.html');

echo 'mensaje enviado correctamente';

?>



Soy muy novata y voy a golpes de pruebas y pruebas.....
¿Alguien me echa una manita?

Muchas gracias

Etiquetas: elementos
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:35.