require '../library/config.php';
require '../library/controlli.php';
require '../smarty/Smarty.class.php';
require '../library/pagineFunctions.php';
require '../library/notizieFunctions.php';
require '../library/prodottiFunctions.php';
$error = FALSE;
$errorMessaggio = "";
if (isset($_GET['pId'])) { $pId = (int)$_GET['pId']; } else { $pId = 5;}
$dettaglioPagina = dettaglioPagina($pId);
$smarty = new Smarty;
$smarty->debugging = false;
$smarty->assign('autore',AUTORE);
$smarty->assign('sito',SITO);
$smarty->assign('nome',NOME);
$smarty->assign('indirizzo',INDIRIZZO);
$smarty->assign('citta',CITTA);
$smarty->assign('email',EMAIL);
$smarty->assign('telefono',TELEFONO);
$smarty->assign('fax',FAX);
$smarty->assign('cellulare',CELLULARE);
$smarty->assign('iva',IVA);
$smarty->assign('facebook',FACEBOOK);
$smarty->assign('website',WEBSITE);
$smarty->assign('skype',SKYPE);
$smarty->assign('title',$dettaglioPagina[0]['title']);
$smarty->assign('keywords',$dettaglioPagina[0]['keywords']);
$smarty->assign('description',$dettaglioPagina[0]['description']);
$smarty->assign('titolo',$dettaglioPagina[0]['nome']);
$smarty->assign('menu', getMenu());
if(empty($_POST)) {
$smarty->display('contatti.tpl');
} else {
foreach($_POST as $key => $value) {
if ($key == 'txtNome' and $value =='' and (!verify_alfaSpec($value)) ){
$errorMessaggio .="Non hai inserito nessun nome.
";
$error = true;
}
if ($key == 'txtEmail' and $value =='' ) {
$errorMessaggio .="Non hai inserito nessun indirizzo email.
";
$error = true;
}
if ($key == 'txtEmail' and $value != '') {
if (!verify_email($value)) {
$errorMessaggio .= 'Non hai inserito un formato email valido.
';
$error = true;
}
}
}
// controllo errori e reindirizzamento
if ($error) {
$smarty->assign($_POST);
$smarty->assign('errore', $errorMessaggio);
$smarty->display('contatti.tpl');
} else {
$nome = trim($_POST['txtNome']);
$email = trim($_POST['txtEmail']);
$telefono = trim($_POST['txtTelefono']);
$messaggio = trim($_POST['txtMessaggio']);
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1\n";
$headers .= "From: " . $email . "\r\n";
$headers .= "Reply-To: ".$email."<".$email.">";
/* indirizzo dove viene spedita il form */
$to = EMAIL;
$subject = "Richiesta informazioni dal sito: www.redlaseritalia.com";
$messagebody = "Nome: ".$nome."
Telefono: ".$telefono."
Email: ".$email."
Messaggio: ".$messaggio;
$mailsent = mail($to, $subject, $messagebody, $headers);
if ($mailsent) {
$smarty->display('contatti_ok.tpl');
} else {
$smarty->display('contatti_ko.tpl');
}
}
}
?>