Developer Support »

Securimage CAPTCHA

Securimage is a nice CAPTCHA by Drew Phillips from phpcaptcha.org . It is supported in FormToEmail-Pro. For support on the CAPTCHA itself, you should consult phpcaptcha.org . This page deals with a common problem experienced by customers using Securimage CAPTCHA with FormToEmail-Pro. The problem is the location of the Securimage files, whereby the form or the script cannot access the files.

CAPTCHA not showing on the form
If the CAPTCHA does not show on your form, then it means that the Securimage files are not where the form code expects them to be. This is a snippet of the code (supplied in the script) for using on your form page to show the CAPTCHA:

<img id="captcha" src="/securimage/securimage_show.php"

The above code means that there should be a /securimage/ directory(folder) off your web root directory, and the file securimage_show.php should be in that /securimage/ directory. So if the form page is called contact.htm and it's in the web root, it would be here:

www.example.com/contact.htm

...the securimage directory would also be off the web root, like so:

www.example.com/securimage/

...the file securimage_show.php would be in the /securimage/ directory because you put all the Securimage files and folders into the /securimage/ directory, so it would be here:

www.example.com/securimage/securimage_show.php

...the CAPTCHA would then be displayed on your screen (assuming your server meets the minimum requirements as stated on phpcaptcha.org).

If the CAPTCHA is not displayed, the problem is often caused by the wrong location being stated in the form code. If you use the default form code (snippet):

<img id="captcha" src="/securimage/securimage_show.php"

...then you MUST have this directory:

www.example.com/securimage/

...and you must upload the Securimage files to it.

You can put the /securimage/ directory anywhere you like, so long as you call it correctly from your form code. You could have this directory on your website:

www.example.com/some_directory/some_other_directory/yet_another_directory/and_one_more_directory_just_for_the_hell_of_it/securimage/

...the code (snippet) on your form would be:

<img id="captcha" src="/some_directory/some_other_directory/yet_another_directory/and_one_more_directory_just_for_the_hell_of_it/securimage/securimage_show.php"

You can also call the file by the URL, like so:

<img id="captcha" src="http://www.example.com/some_directory/some_other_directory/yet_another_directory/and_one_more_directory_just_for_the_hell_of_it/securimage/securimage_show.php"

So long as the form is looking in the correct place for the Securimage files, and you have made a /securimage/ directory and uploaded the Securimage files to it, and your server meets the minimum requirements, then the CAPTCHA will be shown.

Note that the default "/securimage/securimage_show.php" occurs twice in the form code. If you need to change it, change both instances. Note also that the form page does NOT need to be a PHP page for Securimage to work.

CAPTCHA error when submitting the form
If there is an error with the Securimage CAPTCHA when submitting the form, you will know this by getting an error message or getting a blank page.

You might get an error like this:

Warning: main(/home/username/public_html/securimage/securimage.php) [function.main]: failed to open stream: No such file or directory in /home/username/public_html/formtoemailpro.php on line 1015

Warning: main() [function.include]: Failed opening '/home/username/public_html/securimage/securimage.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/username/public_html/formtoemailpro.php on line 1015

Fatal error: Cannot instantiate non-existent class: securimage in /home/username/public_html/formtoemailpro.php on line 1017

If you get a blank page, you are probably getting the same error but due to your PHP settings, the error isn't shown on the screen. Have a look in your error log (from your website control panel).

The key to this error is:

"No such file or directory"

Just like the problem with the CAPTCHA not showing on the form, the problem here is that the script (formtoemailpro.php) cannot find the Securimage file.

This is the default line of code in the script that locates the Securimage file:

include_once dirname(__FILE__) . '/securimage/securimage.php';

This is slightly different to the code used in the form. The code is looking for the /securimage/ directory RELATIVE to the directory that the script is in. It may or MAY NOT be the web root directory. Best shown by example:

If the script is here:

www.example.com/formtoemailpro.php

...the script will look for this directory:

www.example.com/securimage/

If the script is here:

www.example.com/scripts/formtoemailpro.php

...the script will look for this directory:

www.example.com/scripts/securimage/

In the script code, you can call the /securimage/ directory and file absolutely, like so:

Change the default line:

include_once dirname(__FILE__) . '/securimage/securimage.php';

...to this(for example):

include_once '/home/username/public_html/securimage/securimage.php';

...or this(for example):

include_once '/home/username/public_html/scripts/securimage/securimage.php';

You will see, as with the form code, that the directory must exist where the script is expecting it. Or to put it another way, when you have made your /securimage/ directory, wherever it is, make sure that the script "points" to it.

Solution
Your form needs to access the /securimage/ directory, as does the script. They both access the same directory (but different files within that directory). You only need to make ONE /securimage/ directory. Make the directory anywhere you like on your webspace then make sure the form code and the script code both point to the directory.

The default coding assumes that the form page and script are in your web root directory. If so, you don't need to change any code, just make the /securimage/ directory off the web root, like this:

www.example.com/securimage/

Suppose your form is on contact.htm in the web root, and the script (formtoemailpro.php) is in the /scripts/ directory, and the /securimage/ directory is off the web root...

The form would be here:

www.example.com/contact.htm

The script would be here:

www.example.com/scripts/formtoemailpro.php

The /securimage/ directory would be here:

www.example.com/securimage/

The snippet of code in the form would be like this (default):

<img id="captcha" src="/securimage/securimage_show.php"

The line of code in the script would be like this:

include_once '/home/username/public_html/securimage/securimage.php';

The above path is shown as an example. You would need to enter the correct path for your server.