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

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.
JuancabritoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
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
JuancabritoAuthor Commented:
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
Ray PaseurCommented:
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
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

JuancabritoAuthor Commented:
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
Ray PaseurCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
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
Ray PaseurCommented:
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
JuancabritoAuthor Commented:
Thank you very much Ray! I'll try it.
0
Ray PaseurCommented:
OK, good luck!
0
JuancabritoAuthor Commented:
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
Ray PaseurCommented:
Please post the output you got from running my example.  I'll try to help. ~Ray
0
JuancabritoAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.