Risolto cosi:
<?PHP
require_once('b2evo_captcha/b2evo_captcha.config.php');
require_once('b2evo_captcha/b2evo_captcha.class.php');
//Initialize the captcha object with our configuration options
$captcha =& new b2evo_captcha($CAPTCHA_CONFIG);
if (isset($_POST['image']))
{
switch($captcha->validate_submit($_POST['image'],$_POST['validcode']))
{
// form was submitted with incorrect key
case 0:
echo '<p><img src="images/lock_fail.png" alt="" /> Spiacente il codice di verifica inserito era errato!!!</p>';
echo '<br/><br/><a href="'.$_SERVER['PHP_SELF'].'">Riprova con il modulo Contatti</a></p>';
break;
// form was submitted and has valid key
case 1:
/*Here we are going to declare the variables*/
$nomeutente = $_POST['nomeutente'];
$cognomeutente = $_POST['cognomeutente'];
$clean = array();
if (ctype_alnum($_GET['email']))
{
$clean['email'] = $_GET['email'];
$email = $_POST['email'];
}else
{
$email = $_POST['email'];
}
//$html = array();
//$html['username'] = htmlentities($clean['username'],ENT_QUOTES, 'UTF8');
//echo "<p>Bentornato, {$html['username']}.</p>";
if(chkEmail($email))
{
$message = $_POST['textutente'];
//Save visitor name and entered message into one variable:
$formcontent="Nome Visitatore: $nomeutente $cognomeutente\n\nMessaggio Lasciato: $message";
$recipient = "
webmaster@sito.it";
$subject = "Richiesta Informazioni dal Sito [
www.sito.it]";
$mailheader = "From: $email\r\n";
$mailheader .= "Reply-To: $email\r\n";
$mailheader .= "MIME-Version: 1.0\r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Failure!");
echo '<p><img src="images/scroll_ok.png" alt="" /> Messaggio spedito correttamente!!</p>';
echo '<br><br><a href="'.$_SERVER['PHP_SELF'].'">Nuovo Messaggio</a></p>';
}else
{
echo '<p><img src="images/email_warning.png" alt="" /> Spiacente indirizzo Email inserito era errato!!!</p>';
echo '<br/><br/><a href="'.$_SERVER['PHP_SELF'].'">Riprova con il modulo Contatti</a></p>';
}
break;
}
}
else {
echo '<p><strong><b><font face="Arial" color="#336699">Potete contattarci compilando il presente modulo </font></b></strong></p>';
echo '<p><img src="images/info.png" alt="" /></p>';
$imgLoc = $captcha->get_b2evo_captcha();
echo '<form name="myForm" class="myForm" enctype="multipart/form-data" action="'.$_SERVER['PHP_SELF'].'" method="POST">'."\n";
?>
<?php
function chkEmail($email)
{
$email = trim($email);
if($email != "") {
// la stringa rispetta il formato classico di una mail?
if(!preg_match( '/^[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}$/', $email))
return false;
else return true;
}
else return false;
}
?>