No al cierre de webs
ShareCode
Permalink: http://www.treeweb.es/u/974/ 01/02/2011

ShareCode

1 <style type="text/css">2 FORM {3 margin:0;4 padding:0;5 border:0;6 width:300px;7 margin: 0 auto;8 }9 10 LEGEND {11 font-size:10px;12 color:gray;13 }14 15 FIELDSET {16 border:none;17 }18 19 FIELDSET DD {20 font-size:12px;21 padding:0;22 margin-left:20px;23 margin-top:10px;24 }25 26 FORM .centrado {27 text-align:center;28 }29 30 FIELDSET INPUT, FIELDSET TEXTAREA {31 width:100%;32 border:solid black 1px;33 }34 </style>35 36 <?php37 38 error_reporting(0);39 40 if (isset($_POST['enviar']) ) {41 42  $error = false;43  $msg_error = '';44  45 46 47  if (!strlen(trim($_POST['nombre']))) {48  $error = TRUE;49  $error_1 = 'border-color:#FF0000;';50  }51 52  if (!filter_var(trim($_POST['email']), FILTER_VALIDATE_EMAIL)) {53  $error = true;54  $error_2 = 'border-color:#FF0000;';55  }56  57  if (!strlen(trim($_POST['tlf']))) {58  $error = TRUE;59  $error_3 = 'border-color:#FF0000;';60  }61 62  if (!strlen(trim($_POST['mensaje']))) {63  $error = TRUE;64  $error_4 = 'border-color:#FF0000;';65  }66 67 68  $mensaje = rawurldecode($mensaje);69  $mensaje = htmlspecialchars($_POST['mensaje']);70  $mensaje = str_replace("\n", '<br>', $mensaje);71  72  if ($error) {73  $mostrar_formulario = TRUE;74  } else {75  $email_contacto = $this->tw->mConfiguracion->leer('FORM_CONTACTO_EMAILS');76  $to = $email_contacto;77  $subject = '[TREEWEB - CONTACTO]';78  $message = '<div style="padding:3px; background-color:#185787; color:white;">Formulario de contacto</div>79 <div style="padding:20px; border:solid #185787 1px; background-color:white;">80 <div style="float:right;">'.date("r").'</div>81 <h2 style="margin:0; padding:0;">'.$_POST['email'].'</h2><br>' .82 'Nombre: '.$_POST['nombre'].'<br>'.83 'Teléfono: '.$_POST['tlf'].'<br>'.84 'Mensaje: <br>'.85 $mensaje.86 '</div>';87  88  $headers = "MIME-Version: 1.0\n" ;89  $headers .= 'Content-Type: text/html; charset=UTF-8'."\n";90  $headers .= "Reply-To: ".trim($_POST['email'])."\n";91  $headers .= "X-Priority: 1 (Higuest)n";92  $headers .= "X-MSMail-Priority: High\n";93  $headers .= "Importance: High\n";94 95  $emails = explode(',', $email_contacto);96  $envio_ok = true;97  foreach ($emails as $e) {98  $envio_ok = $envio_ok & mail(trim($e), $subject, $message, $headers);99  }100 101  if ($envio_ok) {102  // Correcto103  echo '<div style="color:green; border:solid green 1px; width:350px; margin:20px auto 0 auto; padding:10px;">Su mensaje ha sido enviado correctamente.<br>Recibirá una respuesta en cuanto estemos disponibles.<br>Gracias</div>';104  } else {105  echo '<div style="color:red; border:solid red 1px; width:350px; margin:20px auto 0 auto; padding:10px;">Error al enviar el mensaje debido a sobrecarga del sistema.<br>Por favor, inténtelo de nuevo más tarde.</div>';106  }107  }108  109 } else {110  $mostrar_formulario = true;111 }112 113 ?>114 115 116 117 118 119 <? if ($mostrar_formulario) { ?>120 <form action="" method="POST" id="formulario_contacto" class="formulario_contacto">121  <fieldset>122  <legend>Los siguientes datos son necesarios:</legend>123  <dl>124  <dd><label for="nombre">Nombre</label></dd>125  <dt><input name="nombre" id="nombre" type="text" size="40" value="<?=$_POST['nombre']?>" style="<?=$error_1 ?>"></dt>126  <dd><label for="email">Email</label></dd>127  <dt><input name="email" id="email" type="text" size="40" value="<?=$_POST['email']?>" style="<?=$error_2 ?>"></dt>128  <dd><label for="tlf">Teléfono</label></dd>129  <dt><input name="tlf" id="tlf" type="text" size="40" value="<?=$_POST['tlf']?>" style="<?=$error_3 ?>"></dt>130  <dd><label for="mensaje">Mensaje</label></dd>131  <dt><textarea name="mensaje" id="mensaje" style="<?=$error_4 ?>"><?=$_POST['mensaje']?></textarea></dt>132  </dl>133 134  </fieldset>135  <div class="centrado"><input name="enviar" id="enviar" type="submit" value="Enviar mensaje"></div>136  <input name="enviar" type="hidden" value="enviar">137 </form>138 <? } else { ?>139 140 <? } ?>
Enlace
El enlace para compartir es: