WHAT TO DO: captcha is not showing or not working?

Talk and info about common issues

Moderators: ne_moj, zewa

administrator
Site Admin
Site Admin
Posts: 5930
Joined: Jan 7th, '09, 23:18
Contact:

WHAT TO DO: captcha is not showing or not working?

Postby administrator » Sep 29th, '10, 03:07

Captcha is NOT SHOWING:
-------------------------------------

Solution 1:
Remove whole modules/captcha/folder and re-upload it again to your server. If this doesn't help, go to Solution #2.

Solution 2:
Open secureimage.php file and replace

Code: Select all

$this->ttf_file  = $this->basepath . '/AHGBold.ttf';
with

Code: Select all

$this->ttf_file  = '/AHGBold.ttf';

If this doesn't help, go to Solution #3.

Solution 3:
This error may come from problems with some installed modules in PHP on your server.
For instance the problem leads to error with imagettftext () function.
Read here for more info: http://php.net/manual/en/function.imagettftext.php

3.1 You need to re-compile PHP with more options.
--with-gd
--enable-gd-native-ttf
--with-png
--with-zlib-dir=/usr/local/lib/zlib-1.2.1
--with-ttf
--with-jpeg-dir=/usr/local/lib/jpeg-6b/
--with-freetype-dir=/usr/local/lib/freetype-2.1.9/
--with-xpm-dir=/usr/X11R6/

3.2. Open modules/captcha/securimage.php and turn $use_gd_font to be true:

Code: Select all

$use_gd_font = true;



Captcha is NOT WORKING:
------------------------------------
WHAT TO DO if Captcha is showing, but not working?

Sometimes you get error: Sorry, the code you have entered was invalid! Please try again. even if you entered a valid code.

Solution 1: (special thanks for - Sugiono Djojo)
1. Create php.ini file with (or add into existing file) following commands:
register_globals=on
use_trans_sid=on
and then copy this file into each sub-directory in modules/captcha/ folder
2. Set the in modules/captcha/secureimage.php
$this->use_sqlite_db = true;

Solution 2:
1. Try to remove php.ini file or .htaccess. Does it help now? If not, follow the next steps.
2. Try to copy current .htaccess file in modules/captcha/ directory. Does it help now? If not, follow the next steps.
3. Download and use latest version of captcha component: http://phpcaptcha.org/
4. One possible source of the problem may be: your server doesn't allow passing of session variables into sub-folders. In this case you may change
settings of captcha module (found in modules/captcha/) so it will work with database:
$this->use_sqlite_db = true; or ask your hosting provider how to allow passing session variables to sub-folders.

administrator
Site Admin
Site Admin
Posts: 5930
Joined: Jan 7th, '09, 23:18
Contact:

2: WHAT TO DO: captcha is not showing?

Postby administrator » Feb 4th, '11, 18:24

Another gotcha to add to this list is that using a relative session.save_path is a VERY BAD idea.

You can just about pull it off, if you're very careful, but note two related points:

1) The path is taken relative to the directory of the ORIGINALLY executed script, so unless all pages are run from the same directory, you'll have to set the directory separately in each individual subfolder

2) If you call certain functions, such as session_regenerate_id(), PHP will try to take the session directory relative to the exectuable, or something like that, creating an error IN the executable. This provides slightly cryptic error messages, like this:

Warning: Unknown: open(relative_path\ilti9oq3j9ks0jvih1fmiq4sv1.session, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (relative_path) in Unknown on line 0

... so don't even bother. Just use

<?php ini_set("session.save_path",dirname(__FILE__)."/relative_path"); ?>

(or equivalent) in a file which you know is always in the same place relative to the file.

{PHP version 5.1.6}

taken from: http://php.net/manual/en/ref.session.php

administrator
Site Admin
Site Admin
Posts: 5930
Joined: Jan 7th, '09, 23:18
Contact:

3: WHAT TO DO: captcha is not showing or not working?

Postby administrator » May 6th, '12, 07:25

Even if I type the correct code, Securimage always says it is wrong.

Original text: http://www.phpcaptcha.org/faq/#incorrect_code

Follow the steps below.
1. Cookies must be enabled in the client’s browser or the validation will always fail!
To allow users with cookies disabled you must use the new SQLite database option in Securimage.

2. Check to make sure the HTML input tag’s name attribute for the captcha code input is the same name that is being checked in your validation code. If your form uses <input type=”text” name=”captcha_code” /> then the form processor must reference $_POST['captcha_code'] when calling $Securimage->check().

3. If the variable names are the same this may be due to a problem with the PHP session that is used to keep track of the user and what their code is. It is possible that the session was not started or more likely that the session name being used in securimage_show.php differs from the session name used in the script that does the code validation. It is common for other software platforms (forums, content management systems, form processors etc.) to use a session name other than the PHP default. If this is the case, you must determine what session name is used by the software and use the same session name in securimage_show.php and securimage_play.php.

A non-default session name can be passed to Securimage so it can share a session with another software platform with the following code: $img->session_name = ‘your_session_name’;

Note: Securimage will NEVER destroy a session so it is safe to use with systems that persist user data with sessions; it only changes its own session variables.


Return to “ApPHP MicroCMS {HOW TO}”