Ecco tutto il codice
codice:
<?php
//Mi connetto al MySql Server
$myconn = mysql_connect('62.149.150.72', 'Sql180071', '7f25d052') or die('Errore MySQL...');
//Mi connetto al database degli amici
mysql_select_db('Sql180071_2', $myconn) or die('Errore DB...');
//CORPO EMAIL
$nome = $utenti3['element_1_1'];
$today = date('d-m-Y', time() + 604800);
$oggetto = '' . $nome . ', Tanti Auguri!';
$msg = '
<html>
<head>
<title>Compleanno - Happy Birthday - LIGHT</title>
</head>
<body bgcolor="#F8F8F8">
<center>
<table width="650" height="50" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="#111111">
<tr>
<th width="650" height="24" bgcolor="#e20077">
<p align="center">
</th>
</tr>
<tr>
<th width="650" height="24" bgcolor="#e20077">
<p align="center"><font face="Arial" color="#F8F8F8" size="14">Happy Birthday</font></th>
</tr>
<tr>
<th width="650" height="20" bgcolor="#F3F3F3">
Oggi si festeggia un giorno speciale
e lo staff dei CENTRI LIGHT lo vuole condividere insieme!
<font color="#e20077">A Te abbiamo riservato la promozione
HAPPY BIRTHDAY!!!
Ti aspettiamo nei nostri centri ma affrettati, la promo scade il "' . $today . '"
</th>
</tr>
</table>
</center></body></html>';
//Image in e-mail
$mailimg = '<center><table border="0" bgcolor="FFFFFF"><tr><td width="650" height="200">
</td></tr></table></center>';
//Mail Body - Position, background, font color, font size...
$body = '<html><head><style><!--body, P.msoNormal, LI.msoNormal{
background-position: top;
background-color: #dedede;
margin-left: 0em;
margin-top: 2em;
font-family: "verdana";
color: "000000";
}
-->
</style>
</head>
</body> ';
//To send HTML mail, the Content-type header must be set:
$headers='MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html;charset=iso-8859-1' . "\r\n";
$headers .= 'From: staff CENTRI LIGHT <no-reply@lightyourlife.it>' . "\r\n";
$bodys .= "$msg
";
$bodys .= "$mailimg";
$body = $body . $bodys;
//DESTINAT CON ARRAY
$utenti="SELECT * FROM ap_form_1 WHERE
MONTH(element_7) = MONTH(CURRENT_DATE) AND
DAY(element_7) = DAY(CURRENT_DATE)";
$result = mysql_query($utenti, $myconn) or die('Errore Query...');
//conto il numero di occorrenze trovate nel db
$numrows = mysql_num_rows($result);
//se il database è vuoto lo stampo a video
if ($numrows==0){
echo "Oggi nessuno compie gli anni!!";
}
//output risultati
while ($list = mysql_fetch_array($result)) {
echo $list['element_1_1'] . " " . $list['element_1_2'] . " " . $list['element_2'] . " " . $list['element_7'] . ",";
$array = date_parse($list['element_7']);
echo " oggi compie " . (date('Y')-$array[year]) . " anni" . "</h6>" . "
";
}
$utenti2 = mysql_query($utenti);
while($utenti3 = mysql_fetch_array($utenti2))
{
$dest=$utenti3['element_2'];
mail($dest, $oggetto, $body, $headers);
echo("L'email e' stata spedita con successo ai destinatari elencati sopra!!");
}
?>