If you are having trouble getting the CAPTCHA image to display, are getting blank pages, or the code is always incorrect, make sure to download the Securimage Test Script, upload it to your website, and open the URL in your web browser.

The test script checks for configuration errors in PHP than can cause Securimage not to work, as well as makes sure your server meets the requirements for using Securimage.






All Questions

  • I get an error that says “Call to undefined function imagecreate()” in securimage.php.

    • AnswerIf this error appears it means PHP does not have GD support which is required for creating images with PHP. Unfortunately, if you get this error Securimage will not work.

      GD has been included with PHP since version 4.3 but some older PHP installations do not support it. You will need to contact your webhost to request GD support, or recompile PHP with GD support if you are running Securimage on your own server.

      See the Installing/Configuring GD page on php.net for more information.

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

    • AnswerIf you have not already done so, please download the Securimage Test Script and follow the directions listed at the top of this FAQ page. Otherwise follow the steps below.

      1. In your form processor, the first line of the script must be

      <?php session_start(); ?>

      If any HTML or whitespace is output before starting the PHP session, then the validation will not work.

      2. 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.

      3. 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().

      4. 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.

  • I get an error that says "Call to undefined function imagecreatetruecolor()" in securimage.php.

    • AnswerThis problem may indicate that your version of PHP does not have GD support as indicated in the previous FAQ question but it is possible that Securimage will still work. Depending on your PHP and GD versions this function may not be defined.

      To have Securimage use the regular imagecreate() function a background image must not be used and transparent text needs to be turned off. Under these two conditions the imagecreate() function will be used.

      Note: This function will not work with GIF images. It is recommended to use the PNG format for your images.

  • I get an error that says "Call to undefined function imagettftext()" in securimage.php.

    • AnswerYour version of PHP does not have FreeType support built in. FreeType must be installed in order to use TTF fonts.

      You can still use Securimage but you will need to use GD fonts instead of TTF fonts. It is advised to use TTF fonts if possible as certain features of Securimage will not work when using GD fonts (i.e. multiple letter colors, image distortion, transparent text, angled text). GD fonts are also system dependent and can be difficult to find.

  • The image appears but there is no text on the image.

    • Answer

      There is a known bug in PHP 5.3.2 that can cause this problem intermittently. If you are using PHP 5.3.2, you may need to upgrade to a newer version.

      If the code does not appear on the image it usually means one of two things. Either the path to the TTF file is incorrect or there is a problem displaying transparent text in the PHP and GD version you are using.

      First see if the text will appear by setting use_transparent_text to false (ex. $img->use_transparent_text = false;).

      If the text still does not appear, you will need to make sure the path to the TTF font file is correct and that the font file is accessible. It is recommended to use an absolute path to the TTF file. This varies between configurations and web hosts but some examples are (/home/yoursite/public_html, /var/site/html for Unix/Linux or C:\inetpub\wwwroot on Windows). If you are unsure of the path, check with your host or try the following code: $img->ttf_file = $_SERVER['DOCUMENT_ROOT'] . '/securimage/font.ttf'; The font name and Securimage folder will depend on where it was uploaded and what font is uploaded.

  • The image does not show up on my HTML page.

    • AnswerMake sure that the URL specified in the HTML img tag points to the proper location of securimage_show.php. To be sure you can use the full address (i.e. http://yoursite.com/securimage/securimage_show.php).

      To verify that another problem doesn't exist, try viewing the image directly in your browser by going to securimage_show.php in your browser.

  • No image appears and nothing shows up when I go to securimage_show.php

    • AnswerA fatal PHP error may have occurred that is preventing the image from displaying and the PHP configuration is not set to show error messages. To enable error display add the following code just after <?php in your securimage_show.php script: ini_set('display_errors', 'on'); error_reporting(E_ALL);

      After saving the file with those changes go to securimage_show.php in your browser to see if any errors are displayed that can help in determining why the image is not showing.

  • I get an error saying "Warning: include(securimage.php) [function.include]: failed to open stream: No such file or directory in ..."

    • AnswerThis means that the path to securimage passed to the include statement was not found. You will need to change the include "securimage.php"; line to point to the correct location. The paths vary between servers and configurations but this is the absolute path to securimage.php. In 99.9% of scenarios using include "/securimage/securimage.php"; is incorrect.

      If you are unsure of your path, contact your host or try changing the include to include $_SERVER['DOCUMENT_ROOT'] . '/securimage/securimage.php';.

  • I get an error on my pages that says "Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at page.php:###) in securimage.php on line ###."

    • AnswerSecurimage depends on PHP sessions to store the CAPTCHA code in between requests to the server. Because most sessions use cookies, a header must be sent to the user's browser and headers MUST be sent before any portion of the page content is displayed.

      Securimage will attempt to attach itself to an existing session but will attempt to create a new one if one does not exist. Because of this, your code must have a session established or securimage.php must be included before any HTML is sent. The easiest way to solve this is to start a session at the very beginning of the first page that is named in the error message (page.php as shown above). To do this use <?php session_start(); ?> on line 1 of the page.

      If you are integrating securimage.php into an existing software platform you should make sure starting a session yourself will not interfere with its operation.

  • I get an error saying "Parse error: parse error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’"

    • AnswerThis error means that your website is using an outdated version of PHP. Securimage requires PHP 5.2 or greater and will not run on PHP 4. If you are getting this error message, consider upgrading PHP or asking that your web host do so.




Leave a Reply

Play CAPTCHA Audio
Reload Image