By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,510 Members | 1,141 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,510 IT Pros & Developers. It's quick & easy.

Image Captcha has messed up php email form

P: 2
Hi guys, (Newbie member here!)

Having some serious difficulty getting our php email system working after implementing an image captcha to stop the hundreds of bots spamming it.

I may as well post the src first:

Subscription Form:

Expand|Select|Wrap|Line Numbers
  1. <form action="newsletter.php" method="post" enctype="multipart/form-data" name="form" id="form">
  2.                                                         <label>Your Email Address:
  4.                                                           <input type="addemail" name="textfield" id="addemail">
  5.                                                         </label>
  6.                                                         <p><img src="CaptchaSecurityImages.php" />
  7.                                                           <br>
  8.                                                           Security Code: 
  9. <input id="security_code" name="security_code" type="text" />
  10. <br>
  11. <input type="submit" name="submit" value="Submit" />
  14. <br>
  15.                                                           </p>
  16.                                                       </form>
PHP File:

if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) {
// Insert your code for processing the form here, e.g emailing the submission, entering it into a database.
$to = "";
$subject = "New Mailing List Entry - $email";
$email = $_REQUEST['addemail'] ;
$message = $_REQUEST['message'] ;
$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers) ;
{print "Thankyou. Your subscription has been successful. You will now be redirected home..."; }

echo "<META http-equiv='Refresh' content='5; url='>";

} else {
{print "Incorrect security code. Please try again. You will now be redirected back..."; }
echo "<META http-equiv='Refresh' content='5; url='>";
// Insert your code for showing an error message here

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Boccaccio Cellars Newsletter Subscription</title>



Now, the problem is, i'm suddely only receiving blank emails, when in order for our subscription program to work it needs their email in the subject line and also in the 'from' field.

Any help appreciated, (You can view the page on

Mar 27 '08 #1
Share this Question
Share on Google+
1 Reply

P: 2
Hmm, still experimenting. Heres another one, the only problem is i'm having problems nesting the IF statement to verify the image captcha. Its commented out because it works without it in there (But is obviously pointless cause it ignores the captcha)

// Hello! welcome to the settings page.
// Here's your two steps guide:

// Instead of put the email address of the mailing list,
// (the same that SendBlaster uses in Manage Subscriptions Section)
// ... please pay attention to the ' ' apostrophes, they must remain around the email address.

$emailmanager = '';

// save this file, and close it. Thank you!


$email = trim($_POST['email']);
$Ok = ereg("^([a-zA-Z0-9_\.-]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", $email);
if ($Ok) {

// {if ($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) )
mail($emailmanager,'Subscribe','','From: '.$email);
//else {alert('Incorrect image entry. Please try again.');

<script language = 'javascript'>
alert('Thank you, your address was added to our Mailing List');

else {
<script language = 'javascript'>
alert('Sorry, please provide a valid Email address.');
Mar 27 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.