bien olukarak voy ha poner los codigos haber si lo estoy haciendo bien:
primero el html del formulario:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>MI WEB</title>
<link href="styles.css" rel="stylesheet" type="text/css" media="all">
</head>
</head>
<body>
<div id="contactform">
<h1>PARA CONTACTAR RELLENE ESTE FORMULARIO:</h1>
<p class="texto">Los campo marcados con <span style="color:#c00;">*</span> son obligatorios</p>
<form id="contact-form" method="post" onsubmit="return emailCheck(this.email.value);" action="send.php">
<fieldset>
<legend>Datos Personales »</legend>
<div>
<label class="texto" for="visitorname">
<span style="color:#c00;">*</span> Nombre:
</label>
<input size="32" type='text' name="name" id="visitorname" title="Tu Nombre" />
<label class="texto" for="visitorsurname">
<span style="color:#c00;">*</span> Apellido:
</label>
<input size="33" type='text' name="surname" id="visitorsurname" title="Tu Apellido" />
</div>
<div style="padding:3px"></div>
<div>
<label class="texto" for="visitormail">
<span style="color:#c00;">*</span> Dirección de correo:
</label>
<input size="23" type="text" name="email" id="visitormail" value="" title="Tu direccion de correo" />
<label class="texto" for="phone">Telefono:</label>
<input onkeyup="var no_digito = /\D/g; this.value = this.value.replace(no_digito , '');" size="33" type="text" name="phone" id="phone" class="text" title="Tu numero de telefono, si lo deseas." />
</div>
<div style="padding:3px"></div>
<div>
<label class="texto" for="url">Pagina Web:</label>
<input size="77" type="text" name="url" id="url" class="text" title="Tu pagina web, si la tienes." />
</div>
<div style="padding:3px"></div>
</fieldset>
<fieldset>
<legend>Envianos tu Mensaje »</legend>
<div>
<label class="texto" for="subject">
<span style="color:#c00;">*</span> Motivo del mensaje:
</label>
<input size="23" onblur='if (this.value == "") {this.value = "Asunto";}' onfocus='if (this.value == "Asunto") {this.value = "";}' value='' type="text" name="sub" id="subject" title="El motivo de tu mensaje" />
</div>
<div style="padding:3px"></div>
<div>
<label class="texto" for="notes">
<span style="color:#c00;">*</span> Cuerpo del Mensaje:
</label>
<textarea onblur='if (this.value == "") {this.value = "Escribe tu mensaje aquí...";}' onfocus='if (this.value == "Escribe tu mensaje aquí...") {this.value = "";}' name="text" id="notes" rows="8" cols="50" 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); "></textarea>
</div>
<div style="padding:3px"></div>
<div>
<label class="texto" for="count">Caracteres disponibles:</label>
<input type="text" name="count" id="counter" value="800" size="2" readonly="readonly"/>
<?php $text_len = preg_match_all('/./', $str, $dummy); ?>
</div>
</fieldset>
<div>
<?php
session_start();
if ($_POST['action'] == "checkdata") {
if ($_SESSION['tmptxt'] == $_POST['tmptxt']) {
echo "Tu mensaje ha sido enviado con exito, una copia del mensaje sera remitido a tu correo.";
} else {
echo "Intentalo nuevamente, has marcado algo mal.";
}
exit;
}
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" class="descdet">
<div class="bordeder">
<strong class="subder"><span style="color:#c00;">*</span> Si no eres un robot marca este codigo de verificacion:</br>
Ingresa el texto mostrado en la imagen
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
[contenido no disponible] <input name="tmptxt" type="text" size="30">
<input name="btget" type="submit" class="boton" value="Enviar »" title="Pulsa una vez para enviar el mensaje, y espera a la pantalla de confirmacion" />
<input name="action" type="hidden" value="checkdata">
<INPUT TYPE="reset" VALUE="Borrar los datos" title="Pulsa aquí para borrar los datos"/>
</form>
</div>
</td>
</tr>
</table>
</div>
</form>
<p class="texto"><span style="color:#c00;">*</span> Campos Obligatorios</p>
<span style="color:red;font-weight:bold;"><?php echo $error ?></span></p>
<script type="text/javascript" src="var.js"> </script>
</div>
</body>
</html>
y ahora el send.php:
<?php
$correo = $_POST['correo'];
$name = $_POST['name'];
$surname = $_POST['surname'];
$email = $_POST['email'];
$url = $_POST['url'];
$phone = $_POST['phone'];
$sub = $_POST['sub'];
$text = $_POST['text'];
$title = "MI PAGINA";
if (empty($name)) $error .= "<p style='color:red;font-size:12px;font-weight:bold;'>No has introducido tu nombre</p>";
if (empty($surname)) $error .= "<p style='color:red;font-size:12px;font-weight:bold;'>No has introducido tu apellido</p>";
if (empty($email)) $error .= "<p style='color:red;font-size:12px;font-weight:bold;'>No has introducido tu direccion de e-mail</p>";
if (empty($sub)) $error .= "<p style='color:red;font-size:12px;font-weight:bold;'>No has introducido un titulo para el mensaje</p>";
if (empty($text)) $error .= "<p style='color:red;font-size:12px;font-weight:bold;'>No has escrito nada en el cuerpo del mensaje</p>";
$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($HTTP_POST_VARS['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) {
echo $error; ?>
<script type='text/javascript'>
setTimeout('history.go(-1)', 4000);
</script>
<?php } else {
include("email.php");
}
?>
el captcha.php:
<?php
session_start();
function randomText($length) {
$pattern = "1234567890abcdefghijklmnopqrstuvwxyz";
for($i=0;$i<$length;$i++) {
$key .= $pattern{rand(0,35)};
}
return $key;
}
$_SESSION['tmptxt'] = randomText(8 );
$captcha = imagecreatefromgif("bgcaptcha.gif");
$colText = imagecolorallocate($captcha, 0, 0, 0);
imagestring($captcha, 5, 16, 7, $_SESSION['tmptxt'], $colText);
header("Content-type: image/gif");
imagegif($captcha);
?>
y ahora email.php:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<div id="contactoform">
<?php
$headers = "From: $email";
$message .= " \n
De: $name $surname \n
E-Mail: $email \n
Telefono: $phone \n
Pagina Web: $url \n
Desde : $title \n
____________________________________ \n
$text
";
$message2 .= "
Gracias por enviar el mensaje con el asunto: $sub.\n
Para tu referencia, se ha anadido el texto original del mensaje al final de este correo.\n
ya puedes entrar en la pagina de mi web\n
pegando este enlace en la barra de busqueda de tu navegador\n
http://www.otra web.com/index.htm
Mensaje Original: \n
$text
";
$headers2 .= "From: $email \n";
$sub2.="Re: $sub";
$message = stripslashes($message);
$message2 = stripslashes($message2);
$message = strip_tags ($message);
$message2 = strip_tags ($message2);
mail("mi correo", $sub, utf8_decode($message), $headers);
mail($email, $sub2, utf8_decode($message2), $headers2);
?>
<head>
<meta content="text/html;charset=iso-8859-1"http-equiv="Content-Type">
<title>MI WEB</title>
<link rel="stylesheet"a href="../styles.css"type="text/css" media="all" >
</head>
<body><h2>MI WEB te da las!Gracias! <h2/>
<h2>Tu mensaje ha llegado sastifactoriamente</h2>
<script type='text/javascript'>
document.write('Volver atras');
</script>
<noscript></noscript></p>
Se ha mandado un e-mail a tu direccion de correo,
</br> puede que haya llegado y lo tomen como correo no deseado,
</br> mira en esta carpeta y guardalo en sitio seguro.
</p>
</div>
</body>
</html>
tambiem tengo var.js:
function emailCheck (emailStr) {
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
alert("Tu dirección de correo no aparece o es incorrecta (comprueba '@' y '.dominio')");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];
for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Tu direccion de correo contiene caracteres no validos.");
return false;
}
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("El dominio de la direccion introducida contiene caracteres no validos.");
return false;
}
}
if (user.match(userPat)==null) {
alert("La direccion de correo parece incorrecta, por favor compruebalo.");
return false;
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray
>255) {
alert("La direccion IP (Internet Protocol) de destino no es correcta!");
return false;
}
}
return true;
}
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr.search(atomPat)==-1) {
alert("La direccion de correo parece incorrecta, por favor compruebalo, incluyendo el uso incorrecto de signos de puntuacion, comas [,] o puntos [.] al final de la direccion.");
return false;
}
}
if (checkTLD && domArr[domArr.length-1].length!=2 &&
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("Tu direccion de correo debe terminar en un dominio o dos letras " + "país.");
return false;
}
if (len<2) {
alert("Falta el nombre del host en tu direccion de correo - compruebalo. O debes de haber añadido un espacio en blanco al final de la dirección - corrije el error e intentalo de nuevo.");
return false;
}
return true;
}
bueno eso estodo espero respuesta. GRACIAS de antemano.
:shock: