
08/05/2009, 10:29
|
 | | | Fecha de Ingreso: diciembre-2007 Ubicación: Venezuela-monagas
Mensajes: 288
Antigüedad: 17 años, 3 meses Puntos: 14 | |
recibo la información de mi formulario así "comunicación" con detalles en los acento como le digo a $message .= "$comments\n\n"; que trate los caracter como se debe
y no lo muestre de esta manera
comunicación y como deberia estar "Comunicación"
Código:
<?php
if (array_key_exists('send', $_POST)) {
//mail processing script
// remove escape characters from POST array
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value) {
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);
}
$to = '[email protected]'; // use your own email address
$subject = 'Contacto de la web';
// list expected fields
$expected = array('name', 'email', 'telefono', 'comments');
// set required fields
$required = array('name', 'email', 'telefono', 'comments');
// create empty array for any missing fields
$missing = array();
// assume that there is nothing suspect
$suspect = false;
// create a pattern to locate suspect phrases
$pattern = '/Content-Type:|Bcc:|Cc:/i';
// function to check for suspect phrases
function isSuspect($val, $pattern, &$suspect) {
// if the variable is an array, loop through each element
// and pass it recursively back to the same function
if (is_array($val)) {
foreach ($val as $item) {
isSuspect($item, $pattern, $suspect);
}
}
else {
// if one of the suspect phrases is found, set Boolean to true
if (preg_match($pattern, $val)) {
$suspect = true;
}
}
}
// check the $_POST array and any subarrays for suspect content
isSuspect($_POST, $pattern, $suspect);
if ($suspect) {
$mailSent = false;
unset($missing);
}
else {
// process the $_POST variables
foreach ($_POST as $key => $value) {
// assign to temporary variable and strip whitespace if not an array
$temp = is_array($value) ? $value : trim($value);
// if empty and required, add to $missing array
if (empty($temp) && in_array($key, $required)) {
array_push($missing, $key);
}
// otherwise, assign to a variable of the same name as $key
elseif (in_array($key, $expected)) {
${$key} = $temp;
}
}
}
// validate the email address
if (!empty($email)) {
// regex to identify illegal characters in email address
$checkEmail = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
// reject the email address if it deosn't match
if (!preg_match($checkEmail, $email)) {
$suspect = true;
$mailSent = false;
unset($missing);
}
}
// go ahead only if not suspsect and all required fields OK
if (!$suspect && empty($missing)) {
// set default values for variables that might not exist
$interests = isset($interests) ? $interests : array('None selected');
$views = isset($views) ? $views : array('None selected');
// build the message
// build the message
$message = '<ul style="Float: left; width: 800px; List-style-type: none;">';
$message .= '<li style="Display:inline; Float: left; Width:50%;">';
$message .= '<h1 style="background:#000000; padding:5px; font-size:16px; color:#FF33CC;">Datos pesonales</h1>';
$message .= "Nombre: $name\n\n";
$message .= "<br />";
$message .= "<br />";
$message .= '<h1 style="background:#CCCCCC; padding:5px; font-size:16px; color: #000000;">Datos de contacto</h1>';
$message .= "Email: $email\n\n";
$message .= "<br />";
$message .= "Telefono: $telefono\n\n";
$message .= "</li>";
$message .= '<li style="Display:inline; Float: left; Width:50%;">';
$message .= '<h1 style="background:#CCCCCC; padding:5px; font-size:16px; color: #000000;">Comentarios:</h1>';
$message .= "$comments\n\n";
$message .= "<li>";
$message .= "<ul>";
// limit line length to 200 characters
$message = wordwrap($message, 400);
// create additional headers
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1\n";
$headers .= 'From: Soporte <[email protected]>';
if (!empty($email)) {
$headers .= "\r\nReply-To: $email";
}
// send it
$mailSent = mail($to, $subject, $message, $headers);
if ($mailSent) {
// $missing is no longer needed if the email is sent, so unset it
unset($missing);
}
}
}
?>
__________________ Lo que se usar (JAVA, Spring MVC, IntelliJ IDEA , GAE, CakePHP, Bootstrap, Underscorejs, jQuery, HTML5, CSS3, JSON, Ajax, Prototype), Aprendiendo a usar Angularjs y Git. |