en contact.php
Código:
en send.php<!DOCTYPE html PUBLIC "-//W3C//DTD XHTMLExtensible HyperText Markup Language 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTDDocument Type Definition/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es"> <head profile="http://gmpg.org/xfn/1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Formulario de Contacto</title> <META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"> <script type="text/javascript"> function stoperror(){ return true } window.onerror=stoperror </script> <link rel="stylesheet" type="text/css" href="style.css" media="screen" /> </head> <body> <div id="contactform"> <h1>Formulario de Contacto</h1> <form id="contact-form" method="post" onsubmit="return emailCheck(this.email.value);" action="email.php"> <fieldset> <legend>Datos Personales »</legend> <div> <label for="visitorname"> <span style="color:c00;">*</span>Nombre: </label> <input type="text" name="name" id="visitorname" title="Tu Nombre" /> </div> <div> <label for="visitorsurname"> <span style="color:c00;">*</span>Apellidos: </label> <input type="text" name="surname" id="visitorsurname" title="Tu Apellido" /> </div> <div> <label for="visitormail"> <span style="color:c00;">*</span>Dirección de correo: </label> <input type="text" name="email" id="visitormail" value="<?php echo $email; ?>" title="Tu dirección de correo" /> </div> <div> <label for="url">Página Web:</label> <input type="text" name="url" id="url" class="text" title="Tu página web" /> </div> <div> <label for="phone">Teléfono:</label> <input type="text" name="phone" id="phone" class="text" title="Tu número de telefono" /> </div> <div> <label for="postcode">Codigo Postal:</label> <input type="text" name="postcode" id="postcode" class="text" title="El codigo postal de tu localidad" /> </div> <div> <input type="submit" id="submit" name="send" value="Enviar »" title="Pulsa una vez para enviar el mensaje, y espera a la pantalla de confirmación" /> </div> </fieldset> <fieldset> <legend>Envianos tu Mensaje »</legend> <div> <label for="subject"> <span style="color:c00;">*</span>Motivo del mensaje: </label> <input type="text" name="sub" id="subject" title="El motivo de tu mensaje" /> </div> <div> <label for="notes"> <span style="color:c00;">*</span>Cuerpo del Mensaje: </label> <textarea name="text" id="notes" rows="" cols="" onkeyup="val=this.value; if (val.length > 800) { alert('Lo siento, has sobrepasado el limite de 800 caracteres'); this.value = val.substring(0,800); } this.form.count.value=800-parseInt(this.value.length); "><?php echo $text; ?></textarea> </div> <div> <label for="count">Caracteres disponibles:</label> <input type="text" name="count" id="counter" value="800" size="2" /> <?php $text_len = preg_match_all('/./', $str, $dummy); ?> </div> </fieldset> </form> <p><span style="color:c00;">*</span>Campos Obligatorios</p> <p><span style="color:red;font-weight:bold;"><?php echo $error ?></span></p> <script type="text/javascript" src="var.js"></script> </div> </body> </html>
Código:
<?php if (empty($name)) $error .= "No has introducido tu nombre"; if (empty($surname)) $error .= "No has introducido tu apellido"; if (empty($email)) $error .= "No has introducido tu dirección de e-mail"; if (empty($sub)) $error .= "No has introducido un titulo para el mensaje"; if (empty($text)) $error .= "No has escrito nada en el cuerpo del mensaje<br/>"; $str = $text; $text_len = strlen($str); if($text_len > 800) { $error .= "Lo siento, has superado el maximo de 800 caracteres en el cuerpo del mensaje. El numero total de caracteres es $text_len - por favor, acorta tu mensaje."; } if($email) { if(isset($_POST['email'])) { if (preg_match('/^[-!$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+@([-0-9A-Z]+\.)+([0-9A-Z]){2,4}$/i',trim($email))) { } else { $error .= "Tu dirección de e-mail contiene un error."; } $ok = TRUE; $ok = eregi( "^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}$", $email, $check); $ok = getmxrr(substr(strstr($check[0], '@'), 1), $dummy); if($ok === false) { $host = substr($email, strpos($email, '@') + 1); if(gethostbyname($host) != $host) { $ok = true; } if ($ok != true) { $error .= "La dirección de e-mail no parece correcta, por favor, compruebalo"; } } } } if($error) { include("index.php"); } else { include("email.php"); } ?>