integrate captcha (securimage) into a email contact form

IN PROGRESS
Bids
3
Avg Bid (USD)
$30
Project Budget (USD)
$30 - $250

Project Description:
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/dj-contact-us.php:9) in /home/djnow/public_html/dj-contact-us.php 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="document.getElementById('captcha').src = '/securimage/securimage_show.php?' + Math.random(); 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/securimage.php';

6.

7.
8. $securimage = new Securimage();

9.

10.
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
15.
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/securimage.php';
$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:
{$scrubbed['phone']}\n\nComments:
{$scrubbed['comments']}";
//Make it no longer than 70 charactors long:
$body = wordwrap($body, 70);
//Send the email:
Mail('',
'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 &amp; 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">
<tr>
<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>
</tr>
<tr>
<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>
</tr>
<tr>
<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>
</tr>
<tr>
<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>
</tr>
<tr>
<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="document.getElementById('captcha').src = '/securimage/securimage_show.php?' + Math.random(); return false">Refresh Image</a></td><td width="53"></td>
</tr>
<tr>
<td></td><td></td>
<td align="center"><input type="hidden" name="submitted" value="TRUE" />
<input class="FORMS-button" type="submit" name="submit" value="Send!"/>
</td><td></td>
</tr>
</table>
</form>
</div>

Skills required:
PHP
About the employer:
Verified
Public Clarification Board
Bids are hidden by the project creator. Log in as the employer to view bids or to bid on this project.
You will not be able to bid on this project if you are not qualified in one of the job categories. To see your qualifications click here.


Hire ClusterStudio
$ 30
in 0 days
Hire xristos678
$ 30
in 1 days
Hire noworries8all
$ 30
in 0 days