Test Foro de elhacker.net SMF 2.1

Programación => Desarrollo Web => PHP => Mensaje iniciado por: toyeslomao en 6 Enero 2015, 22:31 PM

Título: [Resuelto] envio de datos carrito de compras y phpmailer
Publicado por: toyeslomao en 6 Enero 2015, 22:31 PM
hola chicos, me llamo carlos, y bueno ando un poco perdido, llevo varias buscando como mandar los datos de mis productos y el precio , he conseguido mandar mensaje y asunto, pero.... dejo el codigo a ver si lo puedo solucionar, gracias

esta es la que enviaria los datos a otra que los recoge y manda el email
Código (php) [Seleccionar]
<?php require_once('Connections/conexionzapatos.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;
}
}

$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
$insertSQL sprintf("INSERT INTO tblcompra (idCompra, idUsuario, fchFecha, intTipoPago, dblTotal, intEstado, strNombre) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['idCompra'], "int"),
GetSQLValueString($_POST['idUsuario'], "int"),
GetSQLValueString($_POST['fchFecha'], "date"),
GetSQLValueString($_POST['intTipoPago'], "text"),
GetSQLValueString($_POST['dblTotal'], "double"),
GetSQLValueString($_POST['intEstado'], "int"),
GetSQLValueString($_POST['strNombre'], "text"));

mysql_select_db($database_conexionzapatos$conexionzapatos);
$Result1 mysql_query($insertSQL$conexionzapatos) or die(mysql_error());

$insertGoTo "recibido.php";
if (isset(
$_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s"$insertGoTo));
}

$maxRows_compra 10;
$pageNum_compra 0;
if (isset(
$_GET['pageNum_compra'])) {
$pageNum_compra $_GET['pageNum_compra'];
}
$startRow_compra $pageNum_compra $maxRows_compra;

$varCompra_compra "0";
if (isset(
$_SESSION["MM_IdUsuario"])) {
$varCompra_compra $_SESSION["MM_IdUsuario"];
}
mysql_select_db($database_conexionzapatos$conexionzapatos);
$query_compra sprintf("SELECT * FROM tblcarrito WHERE tblcarrito.idUsuario = %s"GetSQLValueString($varCompra_compra"int"));
$query_limit_compra sprintf("%s LIMIT %d, %d"$query_compra$startRow_compra$maxRows_compra);
$compra mysql_query($query_limit_compra$conexionzapatos) or die(mysql_error());
$row_compra mysql_fetch_assoc($compra);

if (isset(
$_GET['totalRows_compra'])) {
$totalRows_compra $_GET['totalRows_compra'];
} else {
$all_compra mysql_query($query_compra);
$totalRows_compra mysql_num_rows($all_compra);
}
$totalPages_compra ceil($totalRows_compra/$maxRows_compra)-1;

$preciototal="ObtenerIVA()/100";
$multiplicador "ObtenerIVA()/100";
$valordelIVA "preciototal * $multiplicador";
$valorconIVA "preciototal * $multiplicador";
$hoy date("Y-m-d");
$Transferencia="Transferencia";
$asunto="Cachemira.com";
$body="body";
$precio="$valorconIVA";
?>

<table width="324" align="center">
<tr>
<td width="316" align="center" bgcolor="#EEEEEE"><strong>Resumen de su compra</strong></td>
</tr>
</table>


<form action="recibido.php" method="post" name="form" id="form1">
<table width="618" height="94" align="center">

<tr bgcolor="#00FFFF">
<td align="center">Productos</td>
<td align="center">Unidades</td>
<td colspan="2" align="center">Total </td>

</tr>
<?php $preciototal 0;?>
<?php do { ?>

<tr bgcolor="#FFECEC" align="center">
<td width="186" height="24" align="right">
<input name="idProducto" type="text" value="<?php echo ObtenerNombreProducto($row_compra['idProducto']); ?>" size="10" /> </td>
<td width="102" align="right"><input type="text" name="idProducto" value="<?php echo $row_compra['intCantidad']; ?>" size="4" align="left" /></td>
<td colspan="2" align="center"><input name="idProducto" type="text" value="<?php echo ObtenerPrecioProducto($row_compra['idProducto']); ?>" size="5" /></td>
<?php $preciototal $preciototal ObtenerPrecioProducto($row_compra['idProducto']);?>

<?php } while ($row_compra mysql_fetch_assoc($compra)); ?><tr>
<td height="27" align="center">
<td align="center">
<td align="center">
</tr>
</table>
</form>
<tr> <table width="618" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="223" height="20"></td>
<td width="137"></td>
<td class="comproducto"><input name="preciototal" type="text" value="<?php 
$multiplicador 
= (100 ObtenerIVA())/100;
$valorconIVA $preciototal $multiplicador;
echo 
$valorconIVA;?>

" /> Euros IVA incluido</td>
</tr>
</table>
<?php $body.='<tr>

<td>Gracias por comprar en la cachemira.com, <br />
a continuacion le remitimos el total de su compra, esperamos verle pronto. 
</tr>'
;
$body.='<tr></tr>';?>




<form id="formulario" method="post" action="recibido.php" enctype="multipart/form-data">

<input type="email" name="email" required>
<input type="hidden" name="mensaje" value="<?php echo $body?>"> <input type="hidden" name="fchFecha" value="<?php echo $hoy ?>" />
<input type="hidden" name="body" value="<?php echo $body ?>" />
<input type="hidden" name="asunto" value="<?php echo $asunto ?>">
<input type="hidden" name="precio" value="125678" />
<input id="submit" type="submit" name="enviar" value="Enviar mail">
</form>

aqui la que recoge y manda

Código (php) [Seleccionar]
<?php
//Librerías para el envío de mail
include_once('phpmailer/class.phpmailer.php');
include_once(
'phpmailer/class.smtp.php');


$para $_POST['email'];
$asunto$_POST['asunto'];
$mensaje $_POST['mensaje']->$precio=$_POST['precio'];
$fchFecha$_POST['fchFecha'] ;
$mensaje $_POST['mensaje'];
$precio=$_POST['precio'];
//Este bloque es importante
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth true;
$mail->SMTPSecure "ssl";
$mail->Host "smtp.gmail.com";
$mail->Port 465;

//Nuestra cuenta
$mail->Username ='@gmail.com';
$mail->Password ' password

//Agregar destinatario

$mail->AddAddress($para);
$mail->Subject = ($asunto);
$mail->Body = $body ;
$mail->precio = ($precio);

//Para adjuntar archivo
//$mail->AddAttachment($archivo['
tmp_name'], $archivo['name']);
$mail->MsgHTML($mensaje,$asunto,$precio);

//Avisar si fue enviado o no y dirigir al index
if($mail->Send())
{
echo'
<script type="text/javascript">
alert("Enviado Correctamente");
window.location="envio_realizado.php"
</script>';
}
else{
echo'
<script type="text/javascript">
alert("NO ENVIADO, intentar de nuevo");
window.location="envio_realizado.php"
</script>';
}
?>



esto es todo, a ver si hay suerte, gracias

Título: Re: envio de datos carrito de compras y phpmailer
Publicado por: EFEX en 7 Enero 2015, 08:00 AM
Aqui hay un problema..

Código (php) [Seleccionar]
$mail->Password = ' password
Título: Re: envio de datos carrito de compras y phpmailer
Publicado por: toyeslomao en 7 Enero 2015, 11:27 AM
no, es que oculte el pasword logicamente, en el original sale mi email y mi paswword
Título: Re: envio de datos carrito de compras y phpmailer
Publicado por: #!drvy en 13 Enero 2015, 15:37 PM
En la pagina que recoges datos, le dices a PHPMailer que el cuerpo de mensaje sea $body, pero, no lo tienes declarado en ningún sitio en esa pagina. Es decir, no lo recoges.

Saludos
Título: Re: envio de datos carrito de compras y phpmailer
Publicado por: toyeslomao en 16 Enero 2015, 17:54 PM
gracias pro responder, ya lo resolvi, no se si de forma muy ortodoxa, pero esta, gracias