The Securimage script is a simple tool that can generate and display a CAPTCHA image, as well as store the string that it generated using session data.
The recipe's code displays the CAPTCHA image by using a standard HTML img tag that uses one of the scripts in the securimage directory as the image path. On the data processing side, our code first starts by calling session_start to reconnect to the session that was initiated by the image generator to store the CAPTCHA code. It then proceeds to check whether the user CAPTCHA text matches the image that was displayed using the check method of the securimage class. Based on this result, we display an error message or continue verifying that the rest of the required data fields have been submitted correctly.
While there are many PHP scripts available to generate CAPTCHA images, this particular one was selected for this recipe since it is an open source script that uses the BSD license, which is compatible with WordPress licensing. This means that you would be able to distribute this script with your plugin on the official WordPress plugin repository.
For more advanced content filtering methods, look up the Akismet API (https://akismet.com/development/api/).