In Progress

integrate captcha (securimage) into a email contact form

Integrate captcha (securimage) into a email form, that has PHP vaildation code already present. Everything seems find, but I keep getting an error of :

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/djnow/public_html/[url removed, login to view]) in /home/djnow/public_html/[url removed, login to view] on line 74

If I remove the session start() it will validate & send the form without check the image. Below is the user guide that I’ve been working off:

Quickstart Guide

Securimage is ready to go out of the box with no configuration required. The CAPTCHA image will use the default settings as configured inside securimage.php.

Integrating the code into your existing form is quite simple. First we will start by modifying your current form to include the CAPTCHA image and a text input for code entry.

1. In the desired position on your form, add the following code to display the CAPTCHA image:

<img id="captcha" src="/securimage/securimage_show.php" alt="CAPTCHA Image" />

2. Next, add the following HTML code to create a text input box:

<input type="text" name="captcha_code" size="10" maxlength="6" />

Note: You can change the maxlength and size properties to match your image settings.

3. The next step is optional, but can be useful to your users if they cannot read the code they are given.

4. The following code can be used to dynamically reload the CAPTCHA image without having to reload the page. Add this in a convenient location near the CAPTCHA image.

<a href="#" onclick="[url removed, login to view]('captcha').src = '/securimage/[url removed, login to view]' + [url removed, login to view](); return false">Reload Image</a>

Now that your form is looking the way it should, we will move onto editing the PHP code that validates the CAPTCHA.

1. Open the PHP file that processes the form data after submission.

You can find this by looking at the action value inside your <form> tag.

Note: In order to use Securimage, your form processor must be written in PHP.

2. On line 1 of the file, add the following code:

<?php session_start(); ?>

It is important to put this at the top of the file before any HTML output.

3. The next few steps will vary depending on how form validation is handled in your code.

4. To check if the code is correct, we will make a call to the Securimage class. The following php code should be integrated into the script that processes your form near any error checking that takes place. It should be between <?php ?> tags.

5. include_once $_SERVER['DOCUMENT_ROOT'] . '/securimage/[url removed, login to view]';



8. $securimage = new Securimage();



This includes the file that contains the Securimage code and creates a new Securimage object.

11. Next we will actually check to see if the code was correct.

12. if ($securimage->check($_POST['captcha_code']) == false) {

13. // the code was incorrect

14. // handle the error accordingly with your other error checking


16. // or you can do something really basic like this

17. die('The code you entered was incorrect. Go back and try again.');

18. }

The call to the check method checks the generated CAPTCHA code to the code entered by the user. If the code was incorrect, we use die to stop the script from executing and preventing the form from being submitted. The user must go back and try again.

That is all it takes to get Securimage working. If you run into any problems, check out the F.A.Q. page, or read through the questions and responses below. If you are still running into trouble and can't get it working, we offer professional installation of Securimage.

Please find code below:

<div id="maincontenttext2pan">

<?php session_start();

// check for form submission:

if (isset($_POST['submitted'])) {

function spam_scrubber($value) {

// List of very bad values:

$very_bad = array('to:', 'cc:', 'bcc:', 'content-type:', 'mime-version:', 'multipart-mixed:', 'content-transfer-encoding:');

// If any of the very bad strings are in

// the submitted value, return an empty string:

foreach ($very_bad as $v) {

if (stripos($value, $v) !== false) return '';


// Replace any newline characters with spaces:

$value = str_replace(array( "\r", "\n", "%0a", "%0d"), ' ', $value);

// Return the value:

return trim($value);

include_once $_SERVER['DOCUMENT_ROOT'] . '/securimage/[url removed, login to view]';

$securimage = new Securimage();

if ($securimage->check($_POST['captcha_code']) == false) {

// the code was incorrect

// handle the error accordingly with your other error checking

// or you can do something really basic like this

die('The code you entered was incorrect. Go back and try again.');


} // End of spam_scrubber() function.

// Clean the form data:

$scrubbed = array_map('spam_scrubber', $_POST);

// Minimal form validation:

if (!empty($scrubbed['name']) &&

!empty($scrubbed['email']) &&

!empty($scrubbed['phone']) &&

!empty($scrubbed['comments']) ) {

//Create the body:

$body = "Name:

{$scrubbed['name']}\n\nEmail Address:

{$scrubbed['email']}\n\nPhone Number:



//Make it no longer than 70 charactors long:

$body = wordwrap($body, 70);

//Send the email:


'Contact Form Submission', $body,

"From: {$scrubbed['email']}");

//Print a message:

echo '<p style="font-weight: bold;

color: #555555"><em>Thankyou for Contacting Us. We will reply to you shortly.</em></p>';

//Clear $_POST (so that the form's not sticky);

$_POST = array();

} else {

echo '<p style="font-weight: bold;

color: #bf1e2e"> Oops, Please fill out all * fields below, so we can assist with your enquiry more quickly.</p>';


} // End of main isset() If.

// Create the HTML form:


<p>Feel free to fill in the below Contact Us Form to receive additional information & we will get back to you shortly.</p>

<br />

<p class="style18">All Information Marked <span class="style4">*</span> Is Required, Before We Can Receive Your Enquiry.</p><br />

<form action="contact-us-painting.php" method="post">

<table width="487" border="0">


<td width="107" class="style8">Full Name<span class="style4">*</span></td>

<td colspan="4"><input type="text" name="name" size="50" maxlength="60" value="<?php if (isset($_POST['name'])) echo $_POST['name']; ?>" /></td>



<td class="style8">Email <span class="style4">*</span></td>

<td colspan="4"><input type="text" name="email" size="50" maxlength="60" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /></td>



<td class="style8">Phone <span class="style4">*</span></td>

<td colspan="4"><input type="text" name="phone" size="50" maxlength="60" value="<?php if (isset($_POST['phone'])) echo $_POST['phone']; ?>" /></td>



<td class="style8">Comments<span class="style4">*</span></td>

<td colspan="4"><textarea name="comments" rows="9" cols="50" ><?php if (isset($_POST['comments'])) echo $_POST['comments']; ?></textarea></td>



<td height="55"><p class="style8">Security Code*</p></td>

<td width="108" align="center"><img src="/securimage/securimage_show.php" alt="CAPTCHA Image" width="100" height="40" id="captcha" />

</td><td width="95" align="center"><input type="text" name="captcha_code" size="10" maxlength="6" /></td>

<td width="102" align="center"><a href="#" class="FORMS-button" onclick="[url removed, login to view]('captcha').src = '/securimage/[url removed, login to view]' + [url removed, login to view](); return false">Refresh Image</a></td><td width="53"></td>




<td align="center"><input type="hidden" name="submitted" value="TRUE" />

<input class="FORMS-button" type="submit" name="submit" value="Send!"/>






Skills: PHP

See more: integrate captcha form, securimage empty session, integrating captcha php contact form, integrate captcha contact forms, send session cache limiter securimage, securimage mail form, working out of your home, working from home email, working from home data input, working from home call center, we ve sent you an email, top it problems, text em, string problems, string match, string find c, start working from home for free, start a call center, reload page clear cache, q find, q email, professional looking email address, problems with match, Post properties , php code contact

About the Employer:
( 110 reviews ) Gold Coast, Australia

Project ID: #632479

Awarded to:


Hello [url removed, login to view] check PMB

$30 USD in 1 day
(15 Reviews)

3 freelancers are bidding on average $30 for this job


Hello. I'm ready to start right away and finish the project within a few hours. Please, contact me via PMB ig you hae any questions.

$30 USD in 0 days
(32 Reviews)

I am ready now to start and solve it for you

$30 USD in 0 days
(2 Reviews)