Ver Mensaje Individual
  #4 (permalink)  
Antiguo 05/10/2003, 02:21
rameltete
 
Fecha de Ingreso: octubre-2003
Mensajes: 9
Antigüedad: 20 años, 7 meses
Puntos: 0
Despues de toda tu ayuda he conseguido hacer lo que dices de enviar las variables que conozco directamente al body del mensaje, pero el contenido de la compra no se como añadirlo al mensaje ya que no se como pasan. Te mando el codigo javascript del formulario y el PHP que tengo para ver si me puedes dar un poco de luz.
ESTE ES EL CODIGO DEL FORMULARIO QUE PROCESA LA COMPRA
<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;
itemlist=itemlist+1;
document.writeln('<INPUT TYPE="hidden" NAME="PRODUCTO'+itemlist+'" VALUE="'+theitem+'" SIZE="20">');
document.writeln('<INPUT TYPE="hidden" NAME="CANTIDAD'+itemlist+'" VALUE="'+thequantity+'" SIZE="20">');
} 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;
}
}
}

</SCRIPT>

Y ESTE EL DEL PHP QUE LAS ENVIA POR EMAIL

<?php
//Procesa las variables recogidas desde formulario.htm del carrito y las envia por email
// Primero definamos con qué método se llamó al Form2Mail
$variables = $_SERVER["REQUEST_METHOD"]=="GET"?$_GET:$_POST;
// redirigir - URL a la que se envia al usuario después de enviado el email
$redirigir = "http://www.host.com/confirmacion.html";
// error - URL a la que se envia al usuario si hubo un error al enviar el email
$error = "http://www.host.com/error.html";
// Formamos el cuerpo del email.
// Code stolen from Cluster(tm)
$msg .= "DATOS DEL CLIENTE:\nEMPRESA: $EMPRESA\nNOMBRE: $NOMBRE\n";
if (!empty($CIUDAD)) {
$msg .= "CIUDAD: $CIUDAD\n";
} else {}
if (!empty($EMAIL)) {
$msg .= "EMAIL: $EMAIL\n";
$MailFrom = $EMAIL;
} else {
$MailFrom = $EMPRESA;
}
$msg .= "TELÉFONO: $TELEFONO\n";
if (!empty($OTROS)) {
$msg .= "OTROS: $OTROS\n\n";
} else {
$msg .= "\n";
}
$msg .= "PRODUCTOS COMPRADOS\n\n";
// Recorremos el array de lo comprado
foreach($variables as $key => $val) {
if (is_array($val)) {
$dato = "$key :\n";
foreach($val as $key => $valor_multiple)
$dato .= "[$key] = $valor_multiple\n";
} else
$dato .= "$key : $val\n";
}
$msg .= $dato;
// agregamos la Ip del visitante
$msg .= "Enviado desde : ".$_SERVER["REMOTE_ADDR"];
// y enviamos el email
if (@mail($MailTo, $topico, $msg, "From: $MailFrom"))
header ("Location: $redirigir");
else
header ("Location: $error");
exit();
?>