Salve ragazzi già so che questa questione è stata discussa più volte ma in questo caso non riesco davvero a capire come risolvere il problema . Ho un form contatti che non invia i caratteri speciali (accenti virgolette etc..) ho provato già a cambiare da utf-8 a iso ma con scarso risultato.
Vi Ringrazio in anticipo e spero che qualcuno mi dia una mano un abbraccio a tutti...
vi posto il codice :
function TB_Contactform($emailTo, $emailCC = FALSE, $sentHeading='Your message was sent successfully', $sentMessage='Please allow up to three days for a reply.') {
if(isset($_POST['submit']))
{
$error = "";
$name = makeSafe($_POST['name']);
$email = makeSafe($_POST['email']);
$message = makeSafe($_POST['message']);
$subject = makesafe($_POST['subject']);
if(empty($name))
{ $error['name'] = "Il campo nome è vuoto."; }
if(empty($email) || !isValidEmail($email))
{ $error['email'] = "Il campo e-mail è vuoto."; }
if(empty($subject))
{ $error['subject'] = "Il campo oggetto è vuoto."; }
if(empty($message))
{ $error['message'] = "Il campo messaggio è vuoto."; }
if(!empty($_POST['antispam']))
{
echo '
We don’t appreciate spam.</p>';
}
elseif(!empty($error))
{
TB_Displayform($error);
}
else
{
$content = $name . ' (' . $email . ') wrote the following on ' . date("r") . "\n\n";
$content .= $message ."\n\n";
$content .= 'IP: '. $_SERVER['REMOTE_ADDR'];
$headers = 'From: '.$name.' <'.$email.'>'."\r\n";
if($emailCC)
{
$headers .= 'CC: '.$emailCC."\r\n";
}
$headers .= 'Reply-To: ' . $email . "\r\n";
$headers .= 'Content-type: text/plain; charset=UTF8';
if(mail($emailTo, $subject, $content, $headers))
{
echo '<h3>'.$sentHeading.'</h3>'."\n";
echo '
'.$sentMessage.'</p>'."\n";
}
}
}
else
{
TB_Displayform();
}
}
function TB_Displayform($error = false) {
echo '<div class="tbContactform">'."\n";
if($error)
{
echo ' <div class="tbErrors">'."\n";
foreach($error as $err)
{
echo '
'. $err . '</p>'."\n";
}
echo ' </div>'."\n";
}
echo ' <form id="tbContactform" method="post" action="">'."\n";
echo '
'."\n";
echo ' <label for="tbname">Nome:</label>'."\n";
echo ' <input type="text" class="text" id="tbname" name="name"';
if(isset($error) && !empty($_POST['name'])) { echo ' value="'.$_POST['name'].'"'; }
echo '/>'."\n";
echo ' </p>'."\n";
echo '
'."\n";
echo ' <label for="tbemail">Email:</label>'."\n";
echo ' <input type="text" class="text" id="tbemail" name="email"';
if(isset($error) && !empty($_POST['email'])) { echo ' value="'.$_POST['email'].'"'; }
echo '/>'."\n";
echo ' </p>'."\n";
echo '
'."\n";
echo ' <label for="tbsubject">Oggetto:</label>'."\n";
echo ' <input type="text" class="text" id="tbsubject" name="subject"';
if(isset($error) && !empty($_POST['subject'])) { echo ' value="'.$_POST['subject'].'"'; }
echo '/>'."\n";
echo ' </p>'."\n";
echo '
'."\n";
echo ' <label for="tbmessage">Messaggio:</label>'."\n";
echo ' <textarea id="tbmessage" name="message">';
if(isset($error) && !empty($_POST['message'])) { echo $_POST['message']; }
echo '</textarea>'."\n";
echo ' </p>'."\n";
echo ' <p class="submit">'."\n";
echo ' <input type="submit" id="tbsubmit" class="submit" name="submit" value="Invia" />'."\n";
echo ' </p>'."\n";
echo ' </form>'."\n".'</div>'."\n";
}
function isValidEmail($email){
return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email);
}
function makeSafe($data)
{
return trim(addslashes(htmlentities(htmlspecialchars(stri p_tags($data),ENT_QUOTES,"UTF-8"))));
}
?>