[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How can I make a web form, using phpmailer, adding captcha and hidden empty field? I need a tutorial.

Posted on 2008-11-13
12
Medium Priority
?
1,874 Views
Last Modified: 2013-12-25
I have a simple web form which is sending me spam emails. I suppose there should be robots, and I want to add an empty field just to avoid them, as someone suggested, and a captcha security code. I'm using phpmailer, but I know only html and a little of php. I need a tutorial please.
0
Comment
Question by:Juancabrito
  • 7
  • 5
12 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 22953201
Rather than try to learn enough PHP and HTML to repair phpmailer, you might want to look for an alternative application.  Have a look at this...

http://www.swiftmailer.org/

HTH, ~Ray
0
 

Author Comment

by:Juancabrito
ID: 22954613
Thank you Ray, I can try it out, but where's how I can include the captcha and the hidden field using swift mailer?
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 22963291
You may not need to do anything at all... An easy way to find out about this issue is to post a question in the developers forum on their web site.  
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Juancabrito
ID: 22965559
That's nice Ray, but I'm paying for this service, going to another forum to wait for the answer doesn't seem fair to me.
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 22968018
Juancabrito: I can give you the code I use for this purpose. You will need to modify both the form and action scripts.  I will post the captcha generator, then the form script changes and finally  the action script changes.  I cannot tell you where to make these changes - you will need to open up the code of PHPMailer and decide that for yourself.

Install this and name it captcha_number.php
<?php // captcha_number.php GENERATE A PICTURE OF A NUMBER
 $data	= base64_decode($_GET['dt']);
 $im	= imagecreate(46,13);
 $bg	= imagecolorallocate($im, 255,255,255);
 $gray	= imagecolorallocate($im, 188,188,188);
 $text	= imagecolorallocate($im, 178,34,34);  // firebrick
 imagestring($im,5,4,0,$data,$text);
 imageline($im,4,12,38,0,$gray);
 imagepng($im);
 imagedestroy($im);
?>

Open in new window

0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 2000 total points
ID: 22968030
Add this sequence to your form script
Human beings only!  Please enter this number:
<img src=captcha_number.php?dt=<?php $x = mt_rand(1000,10000); echo base64_encode($x);?> />
<input type=hidden name='_newMd5' value =<?=md5($x)?> />
<input name="_newCode" type="text" maxlength="64" size="6" autocomplete="off" />

Open in new window

0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 2000 total points
ID: 22968038
Add this sequence to your action script
// AVOID INVALID SECURITY CODES
$newCode	= $_POST["_newCode"];
$newMd5		= $_POST["_newMd5"];
$newCode	= md5($newCode);
if ($newCode != $newMd5) {
	die("Captcha Error");
}

Open in new window

0
 

Author Comment

by:Juancabrito
ID: 22968798
Thank you very much Ray! I'll try it.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 22968931
OK, good luck!
0
 

Author Comment

by:Juancabrito
ID: 23006707
Somehow every captcha solution available it works in my local server (XAMPP) but when I publish the form is sent anyway, even leaving the captcha code field empty.

Please help.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 23007069
Please post the output you got from running my example.  I'll try to help. ~Ray
0
 

Author Comment

by:Juancabrito
ID: 23007993
This is happening with iCaptcha, reCAPTCHA, and others... and what I get is the "...your message was succesfully sent..." kind of message or page, and the email arrives.
0

Featured Post

Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month19 days, 2 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question