Ver Mensaje Individual
  #5 (permalink)  
Antiguo 26/07/2011, 09:35
Txalito
 
Fecha de Ingreso: febrero-2010
Mensajes: 11
Antigüedad: 14 años, 2 meses
Puntos: 0
Respuesta: Caracteres latinos no se escriben correctamente en formularios

Sigue escribiendo mal los caracteres al enviar el mail, no sé si estoy escribiendo bien el codigo o si el form deberia tener el accept-charset="UTF-8".

El codigo que genera el mail está asi:

Código PHP:
<?php 
$your_email 
='[email protected]';

session_start();
$errors '';
$name '';
$visit_email '';
$user_message '';
$name_0 '';
$visit_email_0 '';
$user_message_0 '';


// INICIO CODIGO FORM SIDEBAR 
if(isset($_POST['submit_side']))
{
    
$name $_POST['name'];
    
$visit_email $_POST['email'];
    
$tel $_POST['tel'];
    
$host1 $_POST['hostini'];
    
$host2 $_POST['hostava'];
    
$host3 $_POST['hostpre'];
    
$registro $_POST['regi'];
    
$emailing $_POST['mailing'];
    
$otros $_POST['otros'];
    
$user_message $_POST['message'];
    
    
///------------Do Validations-------------
    
if(empty($name)||empty($visit_email))
    {
        
$errors .= "Name and Email are required fields. ";    
    }
    if(
IsInjected($visit_email))
    {
        
$errors .= "Bad email value!";
    }
    if(empty(
$_SESSION['6_letters_code'] ) ||
      
strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0)
    {
        
$errors .= "El código de verificación no coincide!";
    }
    
    if(empty(
$errors))
    {
        
//send the email
        
$to $your_email;
        
$subject="Consulta rápida > Lightfaro hosting";
        
$from $your_email;
        
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
        
        
$body  "$name ha enviado la siguiente consulta desde Lightfarohosting.com\n\n".
        
"Nombre: $name\n".
        
"e-mail: $visit_email\n".
        
"Tel.: $tel\n\n".
        
"SERVICIO/S DE INTERES:\n".
        
"$host1 - $host2 - $host3 - $registro - $emailing - $otros\n\n".
        
"Comentarios:\n".
        
"$user_message\n\n".
        
"IP: $ip\n";    
        
        
$headers "From: $visit_email \r";
        
        
// To send HTML mail, the Content-type header must be set
        //$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        
$headers .= 'Content-type: text/plain; charset=utf-8' "\r\n"//PLANO 
        
        
$name=utf8_decode($name); 
        
$user_message=utf8_decode($user_message); 
                    
        
mail($to$subject$body$headers);
        
        
header('Location: index-ok.php');
        
    }
// FIN CODIGO FORM SIDEBAR

// Function to validate against any email injection attempts
function IsInjected($str)
{
  
$injections = array('(\n+)',
              
'(\r+)',
              
'(\t+)',
              
'(%0A+)',
              
'(%0D+)',
              
'(%08+)',
              
'(%09+)'
              
);
  
$inject join('|'$injections);
  
$inject "/$inject/i";
  if(
preg_match($inject,$str))
    {
    return 
true;
  }
  else
    {
    return 
false;
  }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />