Hi, I got a problem mailing my sesion per e-mail.
The problem I got is the following:
If I send the sesion to the mail y get in my postbox for every item added to the sesion a mail and finally a mail with all the items added. So if I add 4 items I get 5 mail 4 with each item added and the final one with the whole items added.
I only want to get the last mail with ALL items but I am having my head f*** up. Please help me here goes the source:
Only mail() part needed to have a look
<?
session_start();
session_register('itemsEnCesta');
if ($descripcion&&$familia1&&$pesetas&&$euros1){
if (!isset($itemsEnCesta)){
$itemsEnCesta[$descripcion][1]=$cantidad;
$itemsEnCesta[$descripcion][2]=$pesetas;
$itemsEnCesta[$descripcion][8]=$familia1;
$itemsEnCesta[$descripcion][5]=$euros1;
}else{
foreach($itemsEnCesta as $k => $v){
if ($descripcion==$k){
$itemsEnCesta[$k][1]+=$cantidad;
$encontrado=1;
}
}
if (!$encontrado) {
$itemsEnCesta[$descripcion][1]=$cantidad;
$itemsEnCesta[$descripcion][2]=$pesetas;
$itemsEnCesta[$descripcion][8]=$familia1;
$itemsEnCesta[$descripcion][5]=$euros1;
}
}
}
if (isset($itemsEnCesta)){
$mensaje = '<div class="title" align=center>Carrito de compras RedesMadrid<br></div>
<table bgcolor=#6699FF cellspacing=0 cellpadding=0 width=100% border=1 bordercolor=white>
<tr>
<td bgcolor=#6699FF bordercolor=white align="center" width="200">
<small>Producto</small>
</td>
<td bordercolor=white align="center" width="100">
<small>Familia</small>
</td>
<td bordercolor=white align="center" width="50">
<small>Cantidad</small>
</td>
<td bordercolor=white align="center" width="100">
<small>Precio</small>
</td>
</tr><table>
';
foreach($itemsEnCesta as $k => $v){
$totalptas += ($v[1] $v[2]);
$totaleuros += ($v[1] $v[5]);
$mensaje.= ' <table bgcolor=#6699FF cellspacing=0 cellpadding=0 width=100% border=1 bordercolor=white>
<tr>
<td bordercolor=white class="small1" bgcolor=white width="200">
'.$k.'
</td>
<td bordercolor=white class="small1" bgcolor=white width="100">
'.$v[8].'
</td>
<td bordercolor=white class="small1" bgcolor=white width="50">
'.$v[1].'
</td>
<td bordercolor=white class="small1" bgcolor=white width="100">
'. number_format($v[2],0) .'/'. number_format($v[5],2) .'
</td>
</table>';
$headers = "MIME-Version: 1.0rn";
$headers .= "Content-type: text/html; charset=iso-8859-1rn";
}
if ($mail='true'){
mail('markck@gmx.net', 'fghfgh' , ''.$mensaje.'' , ''.$headers.'');
}
}
?>
<head>
<style>
SMALL {
font-family:verdana; font-size:8pt; color:#FFFFFF; font-weight: bold
}
.SMALL1 {
font-family:verdana;font-size:8pt; color:#000000
}
.title {font-family:verdana; font-size:14pt; color:#000000
}
a:link {Text-decoration: none; color: black}
a:hover {Text-decoration: underline}
</style>
<link href="style.css" rel=stylesheet title=grstyles type=text/css>
</head>
<body onload="focus(this)">
<?
if (isset($itemsEnCesta)){
echo '<div class="title" align=center>Carrito de compras RedesMadrid<br></div>
<table bgcolor=#6699FF cellspacing=0 cellpadding=0 width=100% border=1 bordercolor=white>
<tr>
<td bgcolor=#6699FF bordercolor=white align="center" width="200">
<small>Producto</small>
</td>
<td bordercolor=white align="center" width="100">
<small>Familia</small>
</td>
<td bordercolor=white align="center" width="50">
<small>Cantidad</small>
</td>
<td bordercolor=white align="center" width="100">
<small>Precio</small>
</td>
</tr><table>
';
foreach($itemsEnCesta as $k => $v){
$totalptas += ($v[1] $v[2]);
$totaleuros += ($v[1] $v[5]);
echo ' <table bgcolor=#6699FF cellspacing=0 cellpadding=0 width=100% border=1 bordercolor=white>
<tr>
<td bordercolor=white class="small1" bgcolor=white width="200">
'.$k.'
</td>
<td bordercolor=white class="small1" bgcolor=white width="100">
'.$v[8].'
</td>
<td bordercolor=white class="small1" bgcolor=white width="50">
'.$v[1].'
</td>
<td bordercolor=white class="small1" bgcolor=white width="100">
'. number_format($v[2],0) .'/'. number_format($v[5],2) .'
</td>
</table>';
}
}
echo '<table bgcolor=#6699FF cellspacing=0 cellpadding=0 width=100% border=1 bordercolor=white>
<tr>
<td bgcolor=#6699FF bordercolor=white class="small1" bgcolor=white width="300" align="right">
<b>TOTAL:</b>
</td>
<td bgcolor=#6699FF bordercolor=white class="small1" bgcolor=white width="200" align="right">
<u>'. number_format($totalptas,0) .' ptas / '. number_format($totaleuros,2) .' € </u>
</td>
</tr>
</table>
<center><a href=carrito.php?mail=true>MAIL</a></center>
';
?>
</body>
Actually you should just look at the mail() and the part before.