Jump to content

Recommended Posts

I started to use prestashop for me and my customers sites. So I feel I must contribute the community. This is my first contribution.

I searched the forum for captcha which working on "contact us" and "authentication (account creation)" form but I did not find any working free module or code. there is a module but the captcha section is too big which I do not prefer. I want a little and simple captcha image. so I make my own. I have to say that I don't know how to develop prestashop module yet, so I load the captcha class from external folder. after I learn to develop prestashop module, I will adapt this solution as a prestashop mudule...

I use (and little modified) this captcha class: http://www.white-hat-web-design.co.uk/articles/php-captcha.php
available in source code below.

I tested this on prestashop 1.3.7 only but probably work on 1.4...

here is the solution;

1) Locate the captcha class: open a folder named "own" in prestashop root and send the class folder (which contains class files) in it. Like this;


2) Modify prestashop files: we will modify 2 files:


in contact-form.tpl:

add this at the beginning of the file

        {php} session_start(); {/php}

before this line (last submit button):

add this:


Captcha code: 
       <input id="security_code" name="security_code" type="text" /><br />

in contact-form.php

add this at the beginning of the file


after this line;

        $errors[] = Tools::displayError('please select a contact in the list');

add this;

        elseif ($_SESSION['security_code'] !== addslashes(htmlspecialchars($_POST['security_code'])))
             $errors[] = Tools::displayError('Wrong captcha code');

Thats all... This is not perfect solution but at least doing job.

I attached the source files below

Note: this is applicable on "authentication (account creation)" form. If you need I can tell and add source code for "authentication (account creation)" form.

I can add several screenshot if you want.

good luck


Share this post

Link to post
Share on other sites
  • 8 months later...

Hello Abraham,


I am really interested about this sollution... Could you please explain the exact places where the files from own/captcha have to be copied?


I am really appreciate your answer...

Thank you very much,




I have got it finally!!!

Thank you!

Edited by balee007 (see edit history)

Share this post

Link to post
Share on other sites
  • 2 years later...
This topic is now closed to further replies.
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More