Unify Theme ERROR! on CAPTCHA form.

For the life of me, I couldn’t figure out why the Sky Forms CAPTCHA was showing ERROR! on my Unify Theme Bootstrap 3 deployment.

Turns out this was just a rookie mistake… I wasn’t looking closely enough at the “how it works” and I was missing some code from the demo-contacts.php sample file that was crucial to the operation of the CAPTCHA. This code generates the CAPTCHA itself and stores it in SESSION data. Since it was missing, the CAPTCHA system’s image.php was turning out an ERROR!

// Make the page validate
ini_set('session.use_trans_sid', '0');

// Create a random string, leaving out 'o' to avoid confusion with '0'
$char = strtoupper(substr(str_shuffle('abcdefghjkmnpqrstuvwxyz'), 0, 4));

// Concatenate the random string onto the random numbers
// The font 'Anorexia' doesn't have a character for '8', so the numbers will only go up to 7
// '0' is left out to avoid confusion with 'O'
$str = rand(1, 7) . rand(1, 7) . $char;

// Begin the session
session_start();

// Set the session contents
$_SESSION['captcha_id'] = $str;

That $_SESSION[‘captcha_id’] is what the image.php file is looking for. If it doesn’t find it, ERROR!

Refresh, and we’re good to go!

-Robbie

0 0 votes
Article Rating
Subscribe
Notify of
guest
5 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
mark wiltshire
mark wiltshire
8 years ago

Thanks Robbie,

Couldn’t see the wood from the trees, all working fantastically now.
Thanks for your help, have a great day 🙂

mark wiltshire
mark wiltshire
8 years ago

Your a STAR Robbie, thanks

Mark WIltshire
8 years ago

Hi Bald Nerd,

I am having this exact trouble and its driving me nuts.

 

Scenario

-> have this working on my dev server (Session stored in files), captcha displays fine.

-> copied files to hosting company. I have 2 issues.

a) I seem to get 2 session files

b) The image.php doesn’t pick up the session (i have added debug statements)

Therefore I always get ERROR displayed.

I have checked permissions of directories. and files and all looks like a match to my local development server.  Any ideas what else I can try.

 

Many thanks for any help you could offer.
Mark