<?
if ($pagina==2){


if ($_POST["attivo"] == "no") {


$sql = "UPDATE a_login


SET attivo='no'


WHERE a_login.id_login = '".$id."'";
mysqli_query($conn, $sql) or die ("errore60 ".mysql_error());


$URL="layer_ins_autorizza.php?id=$id&pagina=4";
header ("Location: ".$URL);


}


elseif ($_POST["attivo"] == "si") {


$sql = "UPDATE a_login


SET attivo='si'


WHERE a_login.id_login = '".$id."'";
mysqli_query($conn, $sql) or die ("errore61 ".mysql_error());




// INIZIO SCRIPT PHPMAILER


require "../phpmailer/class.phpmailer.php";
$messaggio = new PHPmailer();


//intestazioni e corpo dell'email
$messaggio->From= ''.$email_utente.'';
$messaggio->FromName= ''.$nome_utente.' '.$cognome_utente.'';
$messaggio->AddReplyTo(''.$email_utente.'');
$messaggio->Subject="Autorizzazione iscrizione";


$messaggio->AddBCC("formazioni@sito.it");
$messaggio->AddAddress(''.$email_utente.'');


$messaggio->Sender= ''.$email_utente.'';


$messaggio->AddEmbeddedImage('/web/htdocs/www.sito.it/home/images/fondo_email.jpg', 'ciccio', 'fondo_email.jpg', 'base64', 'image/jpeg');


//inseriamo i tag HTML e i CSS per formattare il messaggio
$html_body = '
<html>
<head>
<style>
.testo1{text-align:right;color: #CF150E; FONT-FAMILY: Verdana; FONT-SIZE: 15px; TEXT-DECORATION: none; font-weight:bold}
.testo2{text-align:right;color: #000000; FONT-FAMILY: Verdana; FONT-SIZE: 12px; TEXT-DECORATION: none; font-weight:bold}
.testo3{text-align:right;color: #666666; FONT-FAMILY: Verdana; FONT-SIZE: 12px; TEXT-DECORATION: none; font-weight:bold}
a.testo3:link {BACKGROUND: none; COLOR: #666666; FONT-SIZE: 12px; FONT-FAMILY: Verdana, Helvetica; TEXT-DECORATION: none; font-weight:bold}
a.testo3:active {BACKGROUND: none; COLOR: #666666; FONT-SIZE: 12px; FONT-FAMILY: Verdana, Helvetica; TEXT-DECORATION: none; font-weight:bold}
a.testo3:visited {BACKGROUND: none; COLOR: #666666; FONT-SIZE: 12px; FONT-FAMILY: Verdana, Helvetica; TEXT-DECORATION: none; font-weight:bold}
a.testo3:hover {BACKGROUND: none; COLOR: #000000; FONT-SIZE: 12px; FONT-FAMILY: Verdana, Helvetica; TEXT-DECORATION: none; font-weight:bold}
</style>
</head>
<body>


<table width="700" height="10" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="right" background="http://www.sito.it/images/fondo_email.jpg">


<table width="680" height="600" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="660" height="160">&nbsp;</td>
<td width="20" rowspan="16">&nbsp;</td>
</tr>
<tr>
<td height="50" align="right" class="testo1"><p>Complimenti '.$nome_utente.' '.$cognome_utente.'<br>
sei stato autorizzato all\'accesso del sito!</p>
<p>A seguire i dati di accesso:</p></td>
</tr>
<tr>
<td height="5" align="right">&nbsp;</td>
</tr>
<tr>
<td height="15" align="right" class="testo2">username: '.$username_utente.'</td>
</tr>
<tr>
<td height="15" align="right" class="testo2">password: '.$password_utente.'</td>
</tr>
<tr>
<td height="15" align="right" class="testo2"> </td>
</tr>
<tr>
<td height="15" align="right" class="testo2"> </td>
</tr>
<tr>
<td height="15" align="right" class="testo2"> </td>
</tr>
<tr>
<td height="15" align="right" class="testo2"> </td>
</tr>
<tr>
<td height="15" align="right" class="testo2"> </td>
</tr>
<tr>
<td height="15" align="right" class="testo2"> </td>
</tr>
<tr>
<td height="15" align="right"> </td>
</tr>
<tr>
<td height="15" align="right" class="testo1">
<a href="http://www.sito.it/registrazione_utente_login.php" class="testo1">per entrare clicca qui</a>
</td>
</tr>
<tr>
<td height="65" align="right">&nbsp;</td>
</tr>
<tr>
<td height="10" align="right" class="testo3">
Ora puoi entrare nella tua pagina personale, inserendo la tua username e la tua password.<br>
<br>
Ti aspettiamo sul sito <a href="http://www.sito.it" class="testo3">www.sito.it</a><br>
Con i nostri migliori saluti, <br>Servizio Clienti
</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>


</td>
</tr>
</table>


</body>
</html>
';


//settiamo il metodo che indica alla classe
//il formato HTML
$messaggio->MsgHTML($html_body);


$messaggio->AltBody="Per poter leggere correttamente questo messaggio è indispensabile che il tuo client di posta elettronica sia abilitato per l'html";




//parte relativa all'invio
if(!$messaggio->Send()){
echo $messaggio->ErrorInfo;
}else{
echo '';
}


// FINE SCRIPT PHPMAILER




$URL="layer_ins_autorizza.php?id=$id&pagina=3";
header ("Location: ".$URL);




}


elseif ($_POST["attivo"] == "") {


$URL="layer_ins_autorizza.php?id=$id&pagina=5";
header ("Location: ".$URL);
}




}
?>