Código HTML :
<form name="phpformmailer" action="http://www.alfonsobotello.com./formulario.php" align="center" method="post">
<div align="center"><center><table bgcolor="#F2F2F2" width="528" cellspacing="6">
<tr>
<td width="499" colspan=2><span class="Estilo1">Formulario de Contacto :</span></td>
</tr>
<tr>
<td align="right" width="159"><small>Nombre y Apellido:</small></td>
<td width="349"><font face="Arial"><input class="inputc" size="29" name="name"></font></td>
</tr>
<tr>
<td align="right" width="159"><font color="#000080" size="1">*</font><small> Email:</small></td>
<td align="left" width="349"><font face="Arial"><input class="inputc" size="29"
name="email"></font></td>
</tr>
<tr align="middle">
<td align="right" width="159"><font color="#000080" size="1">*</font><small> Confirmar Email:</small></td>
<td width="349" align="left"><font face="Arial"><input class="inputc" size="29"
name="email2"></font></td>
</tr>
<tr>
<td align="right" width="159"><font color="#000080" size="1">*</font><small> Asunto:</small></td>
<td width="349"><font face="Arial"><input class="inputc" size="29" name="thesubject"></font></td>
</tr>
<tr>
<td align="right" width="159"> <p><font color="#000080" size="1">*</font><small> Mensaje:</small></td>
<td width="349"><textarea style="FONT-SIZE: 10pt" name="themessage" rows="7" cols="27"></textarea></td>
</tr>
<tr>
<td width="159"></td>
<td width="349"><p>
<script language="JavaScript"><!--
function validateForm()
{
var okSoFar=true
with (document.phpformmailer)
{
var foundAt = email.value.indexOf("@",0)
if (foundAt < 1 && okSoFar)
{
okSoFar = false
alert ("Ingrese un Email Valido.")
email.focus()
}
var e1 = email.value
var e2 = email2.value
if (!(e1==e2) && okSoFar)
{
okSoFar = false
alert ("El Email ingresado no es igual a la confirmacion. Ingrese el mismo nuevamente.")
email.focus()
}
if (thesubject.value=="" && okSoFar)
{
okSoFar=false
alert("Ingrese el Asunto.")
thesubject.focus()
}
if (themessage.value=="" && okSoFar)
{
okSoFar=false
alert("Ingrese el mensaje.")
themessage.focus()
}
if (okSoFar==true) submit();
}
}
// --></script>
<input type="button" class="button"
value="Enviar" name="B1" ONCLICK="javascript:validateForm()">
<label></label>
<small><small>Debe llenar los campos marcados con *</small></small> </p>
</td>
</tr>
</table>
</center></div>
</form>
Código PHP :
<?php // ------- aqui lo configuro ------------------------------------------------------- $valid_ref1="http://www.xxxxxxxxxxx.com./base.html";// dominio $valid_ref2="http://www.xxxxxxxxxxx.com./base.html";// dominio $replyemail="[email protected]";//email // ------------------------------------------------------------ //clean input in case of header injection attempts! function clean_input_4email($value, $check_all_patterns = true) { $patterns[0] = '/content-type:/'; $patterns[1] = '/to:/'; $patterns[2] = '/cc:/'; $patterns[3] = '/bcc:/'; if ($check_all_patterns) { $patterns[4] = '/\r/'; $patterns[5] = '/\n/'; $patterns[6] = '/%0a/'; $patterns[7] = '/%0d/'; } //NOTE: can use str_ireplace as this is case insensitive but only available on PHP version 5.0. return preg_replace($patterns, "", strtolower($value)); } $name = clean_input_4email($_POST["name"]); $email = clean_input_4email($_POST["email"]); $thesubject = clean_input_4email($_POST["thesubject"]); $themessage = clean_input_4email($_POST["themessage"], false); $error_msg='ERROR - no enviado. Intente nuevamente.'; $success_sent_msg='<p align="center"><strong> </strong></p> <p align="center"><strong>Su mensaje ha sido enviado<br> </strong> y contestaremos a la brevedad posible.</p> <p align="center">Ademas le hemos enviado una copia de su pedido.</p> <p align="center">Gracias por contactarse.</p>'; $replymessage = "Hola $name Gracias por su mensaje. Contactaremos con usted a la brevedad posible, muchas gracias Por favor no responda a este correo. Su Email: $email -------------------------------------------------- Asunto: $thesubject Mensaje: $themessage -------------------------------------------------- Gracias"; // email variable not set - load $valid_ref1 page if (!isset($_POST['email'])) { echo "<script language=\"JavaScript\"><!--\n "; echo "top.location.href = \"$valid_ref1\"; \n// --></script>"; exit; } $ref_page=$_SERVER["HTTP_REFERER"]; $valid_referrer=0; if($ref_page==$valid_ref1) $valid_referrer=1; elseif($ref_page==$valid_ref2) $valid_referrer=1; if(!$valid_referrer) { echo "<script language=\"JavaScript\"><!--\n alert(\"$error_msg\");\n"; echo "top.location.href = \"$valid_ref1\"; \n// --></script>"; exit; } $themessage = "Nombre: $name \nMensaje: $themessage"; mail("$replyemail", "$thesubject", "$themessage", "From: $email\nReply-To: $email"); mail("$email", "$thesubject", "$replymessage", "From: $replyemail\nReply-To: $replyemail"); echo $success_sent_msg; ?>
