LexiConn Knowledgebase

Knowledgebase Home | Favorites Knowledgebase Home | Favorites
Search the Knowledgebase Browse by Category
Creating a formmail.php form with CAPTCHA functionality that does not require cookies
Article Details

Last Updated
5th of September, 2014

User Opinions (3197 votes)
57% thumbs up 42% thumbs down

How would you rate this answer?
Not helpful

Using the CAPTCHA feature in formmail.php requires that users have cookies enabled in their browser to successfully submit your form. A user not accepting cookies from your site would receive an error such as this:

Error=Failed to obtain authorization to send you email

Fortunately there is a workaround that will allow users blocking cookies to submit a form without compromising the integrity of the CAPTCHA check; however, it requires a few simple steps to convert your form into a PHP script that uses sessions to store the same data on the server.

Here is a step-by-step procedure to convert your existing HTML form to a PHP form than will implement sessions:

1. Rename the file containing your form by changing then file extension from .htm (or .html) to .php:


2. Add a PHP call to start a new session just above the very first, opening tag in your file:

3. You will need to append the PHP session ID to the following URLs in your form using this format:

In the URL to call formmail.php:

<form method="post" action="http://www.yoursite.com/formmail.php">


<form method="post" action="http://www.yoursite.com/formmail.php?<?php echo SID; ?>">

In the URL to call verifyimg.php:

<img src="verifyimg.php" ...


<img src="verifyimg.php?<?php echo SID; ?>"

In the Javascript call to reload the image (if applicable):

document.vimg.src = "verifyimg.php";


document.vimg.src = "verifyimg.php?<?php echo SID; ?>";

Now your form will function properly for all users, even if they do not have cookies enabled.

Related Articles
No attachments were found.

Powered by Interspire Knowledge Manager Knowledgebase Software