• home
  • forum
  • my
  • kt
  • download
  • PHP Spam Terminator - protect your site from annoying spam posts

    Author: 2008-08-16 10:54:52 From:

    Anyone who operates their own website knows that you need to provide forms in your site for visitors to contact you. The big challenge is providing easy form access to your visitors, without letting SPAM flood your email inbox or database. The techniques described in this article tell you how to reduce the amount of SPAM.

    1, Form Validation on the Client Side using Javascript

    Client Side Forms validation is essential -- it saves time and bandwidth. It points out to the user where they've gone wrong in filling out the form.

    Here is a sample of client side form validation using javascript

    ****** Javascript Code **************

    <script language="JavaScript">
    function checkCatalogForm(obj)
    {
    var regex = /^[A-Za-z_0-9'\.\-]+@[A-Za-z_0-9'\.\-]+(\.\w+)+$/;
    var emailTest = regex.exec(document.catalog_form.bio_email.value);

    if(document.catalog_form.bio_name.value == '')
    {
    alert( "You must supply a first name. " );
    document.catalog_form.bio_name.focus();
    return false;
    }
    else if(!emailTest)
    {
    alert("You must supply a valid email address.");
    document.catalog_form.bio_email.focus();
    document.catalog_form.bio_email.value = '';
    return false;
    }
    else
    {
    return true;
    }
    }
    </script>

    ************ HTML Code *********

    <form method="POST" action="xxxx.php" name="catalog_form" onSubmit="return checkCatalogForm();">
    <tr>
    <td colspan="2" align="right" valign="top">

    <p align="center">Fields marked with an asterisk (<strong><font color="#FF0000">*</font></strong>)
    are required.</p></td>
    </tr>
    <tr>

    <td width="50%" align="right" valign="top"><strong><font color="#FF0000">*</font>
    Name : </strong></td>
    <td width="50%" align="left" valign="top"> <input name="bio_name" type="text" size="50" >
    </tr>
    <tr>

    <td align="right" valign="top"><strong><font color="#FF0000">
    *</font> Email : </strong> </td>
    <td valign="top" align="left"> <input name="bio_email" type="text" size="50" >
    </tr>
    <tr>

    <td height="26" align="right" valign="center"><strong>Which product
    are you interested?</strong> </td>

    <td valign="top" align="left"><input name="product" type="text" size="50" >
    </td>
    </tr>
    <tr>
    <td height="26" align="right" valign="center"><strong>How did you
    hear about us? </strong> </td>

    <td valign="top" align="left">
    <input type="other" name="other" size="50" > </td>
    </tr>
    <tr>
    <td height="26" align="right" valign="top"><strong>Questions or
    Comments :</strong> </td>

    <td valign="top" align="left"> <textarea name="bio_comments" cols="40" rows="5"></textarea></td>
    </tr>
    <tr>
    <td height="26" align="right" valign="top">&nbsp;</td>
    <td valign="top" align="left"><input type="submit" value="Submit Request" name="B1">
    <input type="reset" value="Reset Form" name="B2"></td>
    </tr>
    <tr>

    <td height="26" colspan="2" align="right" valign="top">&nbsp; </td>
    </tr>
    </form>

    2, Form Validation on the Server Side using Javascript

    On the server side, you need to check if user fill all required fields.

    3, Using verification word to stop robots to send spam

    "verification word" is an image generated by system randomly and dynanically. A spambot cannot submit a form without providing correct text in the image.

    Here is a demo site using verification word.

    discuss this topic to forum

    relation tutorial

    No relevant information

    Category

      Ad Management (4)
      Calendars (3)
      Chat Systems (7)
      Content Management (6)
      Cookies and Sessions (8)
      Counters (8)
      Database Related (8)
      Date and Time (9)
      Development (6)
      Discussion Boards (7)
      E Commerce (6)
      Email Systems (9)
      Error Handling (5)
      File Manipulation (10)
      Flash and PHP (4)
      Form Processing (7)
      Guestbooks (8)
      Image Manipulation (3)
      Installing PHP (5)
      Introduction to PHP (9)
      Link Indexing (6)
      Mailing List Management (8)
      Miscellaneous (10)
      Networking (6)
      News Publishing (6)
      OOP (8)
      PEAR (6)
      PHP vs Other Languages (2)
      Polls and Voting (5)
      Postcards (0)
      Randomizing (8)
      Redirection (8)
      Searching (6)
      Security (10)
      Site Navigation (16)
      User Authentication (14)
      WAP and WML (7)
      Web Fetching (8)
      Web Traffic Analysis (15)
      XML and PHP (16)

    New

    Hot