Formulario de Contacto
Página 1 de 1.
Formulario de Contacto
index
- Código:
<html>
<head>
<title>Contacto</title>
<SCRIPT LANGUAGE="JavaScript">
<!-- llamada al formulario de mail
function contacto()
{
open('contacto.html', 'Sizewindow', 'width=300,height=350,scrollbars=no,toolbar=no')
}
//-->
</SCRIPT>
</head>
<body>
<form>
<input type="button" name="sizewindow" title="Asesoramiento por E-mail" value="Contacto" style="font: 12px verdana;" onclick="contacto()">
</form>
</body>
</html>
contacto.html
- Código:
<html>
<head>
<title>Contacto</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
</head>
<body onload="DrawCaptcha();">
<a name="feedback"></a>
<form method="post" action="mail.php">
<center>E-mail:<br>
<input style="width:246px;margin-center:5%" type="text" name="email_address" value="" maxlength="100" />
</center>
<textarea name="msg" rows="13" style="width:250px;margin-left:5%;font-size:8pt;font-family:Arial;"></textarea>
<input type="hidden" name="feedback" value="1"/>
<input style="width:90%;margin-left:5%" type="submit" type="submit" value="enviar comentario"/>
<center>
<input type="text" id="txtCaptcha" style="" readonly/>
<input type="text" id="txtInput" pattern="\w{8,9}" placeholder="< Escribe el Captcha" title="Escribe el Captcha" style="" maxlength="8" required/>
<input type="button" id="btnrefresh" value="Recargar Captcha"
style="" onclick="DrawCaptcha();" />
</center>
</form><br/>
<script type="text/javascript">
function DrawCaptcha() { // crea numeros random para ingresar
var a = Math.ceil(Math.random() * 10)+ '';
var b = Math.ceil(Math.random() * 10)+ '';
var c = Math.ceil(Math.random() * 10)+ '';
var d = Math.ceil(Math.random() * 10)+ '';
var e = Math.ceil(Math.random() * 10)+ '';
var f = Math.ceil(Math.random() * 10)+ '';
var g = Math.ceil(Math.random() * 10)+ '';
var code = a + ' ' + b + ' ' + ' ' + c + ' ' + d + ' ' + e + ' '+ f + ' ' + g;
document.getElementById("txtCaptcha").value = code
}
function ValidCaptcha() { // valida los numeros ingresados
var str1 = removeSpaces(document.getElementById('txtCaptcha').value);
var str2 = removeSpaces(document.getElementById('txtInput').value);
if (str1 == str2){
return true; } // son iguales devuelve True
else {
return false; } // son distintos devuelve False
}
function removeSpaces(string) { // saca los espacios del los numeros ingresados
return string.split(' ').join('');
}
</script>
</body>
</html>
error.html
- Código:
<html>
<head>
<title>error</title>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
</head>
<body>
error
</body>
</html>
gracias.html
- Código:
<html>
<head>
<title>gracias</title>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
</head>
<body>
Su mensaje fue enviado.<br>
En el transcurso del dia,<br>
sera respondido.<br>
<br>
Gracias.
</body>
</html>
mail.php
- Código:
<html>
<head>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
</head>
<body>
<?php
// This function checks for email injection. Specifically, it checks for carriage returns - typically used by spammers to inject a CC list.
function isInjected($str) {
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str)) {
return true;
}
else {
return false;
}
}
// Load form field data into variables.
$email_address = $_REQUEST['email_address'] ;
$msg = $_REQUEST['msg'] ;
// If the user tries to access this script directly, redirect them to feedback form,
if (!isset($_REQUEST['email_address'])) {
header( "Location: contacto.html" );
}
// If the form fields are empty, redirect to the error page.
elseif (empty($email_address) || empty($msg)) {
header( "Location: error_message.html" );
}
// If email injection is detected, redirect to the error page.
elseif ( isInjected($email_address) ) {
header( "Location: error.html" );
}
// If we passed all previous tests, send the email!
else {
mail( "mimail@.com.ar", "feedback mi web",
$msg, "From: $email_address" );
header( "Location: gracias.html" );
}
?>
</body>
</html>
Arreglos del captcha
Página 1 de 1.
Permisos de este foro:
No puedes responder a temas en este foro.