Foros del Web » Programando para Internet » PHP »

pido a los expertos ayuda con envio de datos

Estas en el tema de pido a los expertos ayuda con envio de datos en el foro de PHP en Foros del Web. stoy haciendo una tienda virtual. mi problema es k al intentar enviar los datos del pedido a la cuenta de correo del administrador. en practica ...
  #1 (permalink)  
Antiguo 04/12/2009, 03:16
 
Fecha de Ingreso: febrero-2009
Ubicación: Milan
Mensajes: 53
Antigüedad: 15 años, 2 meses
Puntos: 0
pido a los expertos ayuda con envio de datos

stoy haciendo una tienda virtual. mi problema es k al intentar enviar los datos del pedido a la cuenta de correo del administrador.

en practica deberia llegarle una mail con los datos del pedido y los datos del cliente que los ordeno.

la mail le llega pero solo se visualizan los datos del pedido pero no los datos del cliente k los ordeno.

se k sta un poco dificil pero vale la pena intentarlo. gracias de antemano

el codigo es el siguiente:

<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
}
}

session_start();

$observaciones = $_POST["observaciones"];

$colname1_rorden = "-1";
if (isset($_SESSION['IdCliente'])) {
$colname1_rorden = (get_magic_quotes_gpc()) ? $_SESSION['IdCliente'] : addslashes($_SESSION['IdCliente']);
}
$colname_rorden = "-1";
if (isset($_SESSION['IdOrden'])) {
$colname_rorden = (get_magic_quotes_gpc()) ? $_SESSION['IdOrden'] : addslashes($_SESSION['IdOrden']);
}

// Recordset para obtener los datos de los productos que formarán parte del pedido

mysql_select_db($database_cbdtienda_alison, $cbdtienda_alison);
$query_rorden = sprintf("SELECT b.codorden, b.codproducto, p.nombreproduc, b.cantidad, p.precio_normal, p.precio_oferta FROM carrito as b, clientes as c, productos as p WHERE b.codorden = '%s' and b.codcliente=c.codcliente and b.codcliente='%s' and b.codproducto=p.codproducto", $colname_rorden,$colname1_rorden);
$rorden = mysql_query($query_rorden, $cbdtienda_alison) or die(mysql_error());
$row_rorden = mysql_fetch_assoc($rorden);
$totalRows_rorden = mysql_num_rows($rorden);

// Recordset para obtener datos del cliente
$colname_rscliente = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_rscliente = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
}
mysql_select_db($database_cbdtienda_alison, $cbdtienda_alison);
$query_rscliente = sprintf("SELECT * FROM clientes WHERE codcliente = '%s'", $colname_rscliente);
$rscliente = mysql_query($query_rscliente, $cbdtienda_alison) or die(mysql_error());
$row_rscliente = mysql_fetch_assoc($rscliente);
$totalRows_rscliente = mysql_num_rows($rscliente);

///generando mensaje para el correo electrónico
$mensaje = '
<table width=513 border=0 cellspacing=0 cellpadding=0>
<tr>
<td width=9></td>
<td align=center>Nº de Orden:' . $row_rorden[codorden] . '</td>
<td width=9></td>
</tr>
</table>
<table width=513 border=1 cellpadding=0 cellspacing=0 bordercolor=#CCCCCC>
<tr>
<td width=27 height=20 align=center bgcolor=#F9F9F9><p>N&ordm;</p></td>
<td width=206 height=20 align=center bgcolor=#F9F9F9><p>Producto</p></td>
<td width=82 height=20 align=center bgcolor=#F9F9F9><p>Cantidad</p></td>
<td width=82 height=20 align=center bgcolor=#F9F9F9><p>Precio</p></td>
<td width=82 height=20 align=center bgcolor=#F9F9F9><p>Subtotal</p></td>
</tr>';

$contador = 0;
do {
$contador = $contador + 1;
if ($row_rorden[precio_oferta] != 0) {
$tPrecio = $row_rorden[precio_oferta];
$subtotal = $row_rorden[cantidad] * $row_rorden[precio_oferta];
} else {
$tPrecio = $row_rorden[precio_normal];
$subtotal = $row_rorden[cantidad] * $row_rorden[precio_normal];
}
$total = $total + $subtotal;
$igv = $total * 0.19;
$neto = $total + $igv;

$mensaje = $mensaje . '
<tr><td height=20 align=center>' . $contador . '</td>
<td height=20><p>' . $row_rorden[nombreproduc] . '</td>
<td height=20 align=center>' . $row_rorden[cantidad] . '</td>
<td width=82 height=20 align=right>' . number_format($tPrecio,2) . '</td>
<td width=82 height=20 align=right>' . number_format($subtotal,2) . '</td>
</tr>';

} while ($row_rorden = mysql_fetch_assoc($rorden));

$mensaje = $mensaje . '
</table>
<table width=513 border=0 cellspacing=0 cellpadding=0>
<tr><td width=428 height=20 align=right>Sub Total : </td><td width=85 align=right bgcolor=#F9F9F9>'. number_format($total,2) . '</td></tr>
<tr><td width=428 height=20 align=right>IGV : </td><td width=85 align=right bgcolor=#F9F9F9>'. number_format($igv,2) . '</td></tr>
<tr><td width=428 height=20 align=right>Neto : </td><td width=85 align=right bgcolor=#F9F9F9>'. number_format($neto,2) . '</td></tr>
</table>
<table width=513 border=0 cellspacing=0 cellpadding=0>
<tr><td width=9 height=30></td><td align=center>Datos del Comprador</td><td width=9></td></tr>
</table>

<table width="519" border="1" cellpadding="0" cellspacing="0">
<tr><td width="40%" height=30 align="right"><p class="precios">Nombre : </p></td><td width="60%">'.$row_rscliente[nombre]. '</td></tr>
<tr><td width="40%" height=30 align="right"><p class="precios">Apellido : </p></td><td width="60%">' .$row_rscliente[apellidos] . '</td></tr>
<tr><td width="40%" height=30 align="right"><p class="precios">Raz&oacute;n Social : </p></td><td width="60%">' .$row_rscliente[razonsocial]. '</td></tr>
<tr><td width="40%" height=30 align="right"><p class="precios">DNI : </p></td><td width="60%">' . $row_rscliente[dni] . '</td></tr>
<tr><td width="40%" height=30 align="right"><p class="precios">Direcci&oacute;n : </p></td><td width="60%">' .$row_rscliente[direccion]. '</td></tr>
<tr><td width="40%" height=30 align="right"><p class="precios">Tel&eacute;fono : </p></td><td width="60%">' .$row_rscliente[telefono]. '</td></tr>
<tr><td width="40%" height=30 align="right"><p class="precios">Email : </p></td><td width="60%">' . $row_rscliente[email]. '</td></tr>
<tr><td width="40%" height=30 align="right"><p class="precios">Observaciones : </p></td><td width="60%">' . $observaciones . '</td></tr>
</table>';

$fecha = date("Y-m-d h:i:s A");
$xCliente = $_SESSION['IdCliente'];
$xOrden = $_SESSION['IdOrden'];

// Agreando datos a pedido
$sql = "insert into pedidos(codorden,codcliente,fechapedido,observacio nes,bruto,igv,total) values('$xOrden','$xCliente','$fecha','$observacio nes','$total','$igv','$neto')";
$result = mysql_query($sql);

// Agreando datos a detalle de pedido
$colname1_rorden = "-1";
if (isset($xCliente)) {
$colname1_rorden = (get_magic_quotes_gpc()) ? $xCliente : addslashes($xCliente);
}
$colname_rorden = "-1";
if (isset($xOrden)) {
$colname_rorden = (get_magic_quotes_gpc()) ? $xOrden : addslashes($xOrden);
}
$query_rorden = sprintf("SELECT b.codorden, b.codproducto, p.nombreproduc, b.cantidad, p.precio_normal, p.precio_oferta FROM carrito as b, clientes as c, productos as p WHERE b.codorden = '%s' and b.codcliente=c.codcliente and b.codcliente='%s' and b.codproducto=p.codproducto", $colname_rorden,$colname1_rorden);
$rorden = mysql_query($query_rorden, $cbdtienda_alison) or die(mysql_error());
$row_rorden = mysql_fetch_assoc($rorden);
$totalRows_rorden = mysql_num_rows($rorden);
do {
$xProducto = $row_rorden[codproducto];
if ($row_rorden[precio_oferta] != 0) {
$xPrecio = $row_rorden[precio_oferta];
} else {
$xPrecio = $row_rorden[precio_normal];
}
$xCantidad = $row_rorden[cantidad];
$sql = "insert into pedidodetalle(codorden,codproducto,precio,cantidad ) values('$xOrden','$xProducto','$xPrecio','$xCantid ad')";
$result = mysql_query($sql);
} while ($row_rorden = mysql_fetch_assoc($rorden));

// Borrando registros del carrito
$sql = "delete from carrito where codorden='$xOrden' and codcliente='$xCliente'";
$result = mysql_query($sql);

$_SESSION['IdOrden'] = "";
unset($_SESSION['IdOrden']);

// datos de correo para el envio de pedido

$sendTo = "aki va el correo del administrador";
$subject = "Orden de Pedido N° " . $xOrden;
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: " . $row_rscliente['email'];
$headers .= "<" . $row_rscliente['email'] . ">\r\n";
$headers .= "Reply-To: " . $row_rscliente['email'];
$message = $mensaje;
mail($sendTo, $subject, utf8_decode($message), $headers);

header("Location: confirmar_envio.php");

mysql_free_result($rscliente);
?>
  #2 (permalink)  
Antiguo 04/12/2009, 07:50
Avatar de maycolalvarez
Colaborador
 
Fecha de Ingreso: julio-2008
Ubicación: Caracas
Mensajes: 12.120
Antigüedad: 15 años, 9 meses
Puntos: 1532
Respuesta: pido a los expertos ayuda con envio de datos

debes usar $message=wordwrap($message,70); para "picar" la cadena en trozos de 70 caracteres (lineas de 70 caracteres) si usas la funcion mail.

te recomiendo phpmailer para envio de mensajes, es muy practica y te permite mayores opciones para el envio efectivo de correos.
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 11:19.