473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Image Captcha has messed up php email form

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:
  3.  
  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" />
  12.  
  13.  
  14. <br>
  15.                                                           </p>
  16.                                                       </form>
  17.  
PHP File:

[PHP]<?php
session_start();
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 = "newsletter@boccaccio.com.au";
$subject = "New Mailing List Entry - $email";
$email = $_REQUEST['addemail'] ;
$message = $_REQUEST['message'] ;
$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print "Thankyou. Your subscription has been successful. You will now be redirected home..."; }

echo "<META http-equiv='Refresh' content='5; url=http://www.boccaccio.com.au'>";

unset($_SESSION['security_code']);
} else {
{print "Incorrect security code. Please try again. You will now be redirected back..."; }
echo "<META http-equiv='Refresh' content='5; url=http://www.boccaccio.com.au/join.html'>";
// Insert your code for showing an error message here
}
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Boccaccio Cellars Newsletter Subscription</title>
</head>

<body>

[/PHP]

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 www.boccaccio.com.au/join.htm)

Cheers.
Mar 27 '08 #1
1 1820
sld87
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)

[PHP]<?php
session_start();
// Hello! welcome to the settings page.
// Here's your two steps guide:

// FIRST:
// Instead of newsletter@test.com 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 = 'newsletter@boccaccio.com.au';

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


error_reporting(0);

$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.');

if(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$UNameFrm))
{
?>
<script language = 'javascript'>
alert('Thank you, your address was added to our Mailing List');
history.go(-1);
</script>
<?
exit();
}
}

else {
if(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$UNameFrm))
{
?>
<script language = 'javascript'>
alert('Sorry, please provide a valid Email address.');
history.go(-1);
</script>
<?
exit();
}
}
?>
[/PHP]
Mar 27 '08 #2

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

Similar topics

7
by: stevenkobes | last post by:
A lot of websites have forms with an image at the bottom containing some distorted / noisy letters and numbers that users must type in to prove they are real people. How do they normally implement...
4
by: tshad | last post by:
I am trying to set up an Image authorization where you type in the value that is in a picture to log on to our site. I found a program that is supposed to do it, but it doesn't seem to work. ...
1
by: julian_m | last post by:
I've, inside an html page, an image which is created through a php file : <img src="<?php echo 'captcha.php'; ?>"> file captcha.php, sends header("Content-type: image/png"); All works...
2
by: julianmlp | last post by:
Note that captcha.php, generates a png image. I know it works well, beacause in page load, I've <img id="mainimage" src"simplecaptcha/captcha.php"> and the image is generated as expected, but...
0
by: want2learn | last post by:
Hi. I have this CAPTCHA image for .Net in C-Sharp and translate it into VB and as Code_Behind. http://www.mbarrick.com/blog/d6plinks/20061221-01 If i run the site/script i get the site but...
7
by: mitchell | last post by:
hi i m using IE 6.0. i want to refresh just the captcha part when the user clicks on an image. i searched for articles on it and got a fairly good understanding of it. but i m still unable to...
4
by: Jeigh | last post by:
My host has been 'upgrading' lately and its caused me a whole mess of problems. The last of which being that my CAPTCHA form no longer works. I remember to get the CAPTCHA working it took me weeks to...
0
by: readnlearn | last post by:
hai, i have written this below code for displaying captcha image whenever i entered incorrect uname,password in login page. for that i disable the controls of captcha like textbox,labels,button and...
10
by: jeddiki | last post by:
Hi, I have a captcha script which should pick up a background image and add some random letters to it and re-display This is the part of the form that the captcha image is part of: <span...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.