Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End wordpress custom contact form captcha

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #43881
    jarc100
    Member

    I 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); ?>

  • Nombre:
  • Correo


Estamos ubicados en la Ciudad de Playa del Carmen Q.Roo y Cuernavaca Morelos.

#130592
jarc100
Member

Hi @FragaGeddon i was looking for a handcraft solution, thanks thought i’ll read about it may be handy.

#130593
jarc100
Member

found 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;
}

Viewing 3 posts - 1 through 3 (of 3 total)