Skip to content

Luventas Web Design

A new blog for developers in PHP, Java and mobile Development

  • Home
  • 2011
  • Juni
  • 27
  • Preserve your mail form for spam

Preserve your mail form for spam

Posted on 27 Juni 20117 September 2011 By luventas 2 Kommentare zu Preserve your mail form for spam
(x)html, PHP

Somehow it is really a tie, that some silly people tries to use other mail forms to send. In the best behaviour, this spam only reaches your own mail account, in the worst way the whole world gest the spam mail from your account. But there is a nice invention called captcha which helps you to preserve your mail from for this kind of spam, which is mostly send by so called bots.These bots are scanning webpages to find mail- or comment forms (like in this blog). If they found such a form, they tries to send spam over this form. With a captcha which is not readable by a bot, you can prevent the sending of the mail.

How can I insert such a captcha on my mail- or other forms. A webblog like WordPress has easy plugins for that and you only have to choose, which plugin you want to use. But what can you do, if you have a „normal“ web page?

I found a very good and free script for including it on your homepage. It is really easy to use. It is called secureimage PHP captcha and can be downloaded on http://www.phpcaptcha.org/.

It is only needed to upload the „secureimage“ folder in your webspace and then you can include it on your page with the form by calling

Source code   
require_once('securimage/securimage.php');

Then it is ready for use. To show it in the complete feature on your page, you have to include following code on the place where it should be shown:
Source code   
<div>
Bitte geben Sie den unten angegebenen Sicherheitscode ein:<br /><br />
<img id="siimage" align="left" style="padding-right: 5px; border: 0"
src="securimage/securimage_show.php?sid=<?php echo md5(time()) ?>" />
 
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"
width="19" height="19" id="SecurImage_as3" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="securimage/securimage_play.swf?audio=securimage/securimage_play.php&bgColor1=#777&bgColor2=#fff&iconColor=#000&roundedCorner=5" />
<param name="quality" value="high" />
 
<param name="bgcolor" value="#ffffff" />
<embed src="securimage/securimage_play.swf?audio=securimage/securimage_play.php&bgColor1=#777&bgColor2=#fff&iconColor=#000&roundedCorner=5"
quality="high" bgcolor="#ffffff" width="19" height="19" name="SecurImage_as3"
align="middle" allowScriptAccess="sameDomain" allowFullScreen="false"
type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
 
<br />
 
<!-- pass a session id to the query string of the script to prevent ie caching -->
<a tabindex="-1" style="border-style: none" href="#" title="Refresh Image"
onclick="document.getElementById('siimage').src = 'securimage/securimage_show.php?sid=' + Math.random(); return false">
<img src="securimage/images/refresh.gif" alt="Reload Image" border="0" onclick="this.blur()" align="bottom" /></a>
</div>
<div style="clear: both"></div>
Sicherheitscode:<br />
 
<!-- NOTE: the "name" attribute is "code" so that $img->check($_POST['code']) will check the submitted form field -->
<input type="text" name="captchacode" size="12" />

On the receiving php code you have to include the same folder like above and call the code them with
Source code   
$image = new Securimage();

To check, if the captcha code was typed in correctly, you can check it with
Source code   
if($image->check($_POST['captchacode'])) {
   //code for sending
}

Thats all. I think, this is really easy and can be included quick.

Print Friendly, PDF & Email

Beitrags-Navigation

❮ Previous Post: Include your family tree in your webpage, new Version
Next Post: Email validation with PHP ❯

You may also like

PHP
Create thumbnail from image with PHP
25 Mai 2011
Genealogy
Create a database from your GEDCOM file, PHP Version
14 Juni 2011
PHP
PDF creation by PHP
21 Mai 2011
(x)html
A stripe should be a stripe
4 Juni 2011

2 thoughts on “Preserve your mail form for spam”

  1. Phil sagt:
    28 Juni 2011 um 01:51 Uhr

    The visual component of securimage is great, however the audio component is vulnerable to attack:

    http://www.idontplaydarts.com/2011/05/exploit-phpcaptcha-securimage/

    Antworten
    1. luventas sagt:
      28 Juni 2011 um 06:19 Uhr

      Thanks a lot for that hint.

      Antworten

Schreibe einen Kommentar Antworten abbrechen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Copyright © 2023 Luventas Web Design.

Theme: Oceanly News by ScriptsTown

Diese Website nutzt Cookies, um bestmögliche Funktionalität bieten zu können. OK, verstanden
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
immer aktiv
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SPEICHERN & AKZEPTIEREN