- This topic is empty.
-
AuthorPosts
-
April 3, 2013 at 10:49 pm #43881
jarc100
MemberI need to add captcha security to a form on my wordpress developed site. Right now works fine but i don’t wanna have any spamming related issue.
I don’t wanna use the reCaptcha system this is the one i like and been using on other site not developed on wordpress.
http://www.white-hat-web-design.co.uk/articles/php-captcha.php
PS: I’m kinda new on wordpress theming.
this is my code:
/*
Template Name: Pagina Contacto
*/if(isset($_POST)) {
if(trim($_POST) === ”) {
$nameError = ‘Por favor escriba su nombre.’;
$hasError = true;
} else {
$name = trim($_POST);
}if(trim($_POST) === ”) {
$emailError = ‘Por favor escriba su correo.’;
$hasError = true;
} else if (!preg_match(“/^:alnum:[a-z0-9_.-]*@[a-z0-9.-]+.[a-z]{2,4}$/i”, trim($_POST))) {
$emailError = ‘Correo electrónico inválido.’;
$hasError = true;
} else {
$email = trim($_POST);
}if(trim($_POST) === ”) {
$commentError = ‘Please enter a message.’;
$hasError = true;
} else {
if(function_exists(‘stripslashes’)) {
$comments = stripslashes(trim($_POST));
} else {
$comments = trim($_POST);
}
}if(!isset($hasError)) {
$emailTo = get_option(‘tz_email’);
if (!isset($emailTo) || ($emailTo == ”) ){
$emailTo = get_option(‘correocontacto’);
}
$subject = ‘[Insigne Studio Español] From ‘.$name;
$body = “Nombre: $name nnCorreo: $email nnComentario: $comments”;
$headers = ‘From: ‘.$name.’ <'.$emailTo.'>‘ . “rn” . ‘Reply-To: ‘ . $email;wp_mail($emailTo, $subject, $body, $headers);
$emailSent = true;
}}
?>
Gracias, su mensaje se ha enviado con éxito.
Lo sentimos pero ocurrió un error. Inténtelo de nuevo.
ID, ‘titulo-contacto’, true); ?>
Estamos ubicados en la Ciudad de Playa del Carmen Q.Roo y Cuernavaca Morelos.
April 3, 2013 at 11:54 pm #130592jarc100
MemberHi @FragaGeddon i was looking for a handcraft solution, thanks thought i’ll read about it may be handy.
April 3, 2013 at 11:55 pm #130593jarc100
Memberfound the solution.
session_start();
if(($_SESSION == $_POST) && (!empty($_SESSION)) ) {
$captcha = trim($_POST);
unset($_SESSION);
} else {
$captchaError = ‘Por favor escriba el código captcha.’;
$hasError = true;
} -
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.