Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9096659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:54:26+00:00 2026-06-16T23:54:26+00:00

Introduction We were dealing with some spam-issue in an earlier project we did and

  • 0

Introduction

We were dealing with some spam-issue in an earlier project we did and prevent any spam bots with the following simple concept. I now want to implement this into a way larger project. Before I do this I wish to optimize it that this works in multiple forms on the same page, but I’m not getting the trick yet or I’m not sure if its worth rebuild this into a more complex version if its useless.

For clarification: I don’t want to deal with CAPTCHA or similar things. Just do a native solution.

Concept

If the user focus any input field of the form an AJAX-Query will be sent where a random hash-tag will be generated and stored into a $_SESSION variable. This hash will be also written into a hidden input-field called spamKey (for example).

After the user submit the form I check if the $_SESSION["spamKey"] variable is equal to the $_POST["spamKey"] variable so I decide to process the query or not.

The code

Simple form

<form action="index.php" method="post" id="formOne">

    <label for='input_eins'>Name</label>
        <input type='text' id='input_eins' name='name' />
    <label for='input_user'>E-Mail</label>
        <input type='text' id='input_user' name='user' />
    <label for='ta_text'>Comment</label>
        <textarea name='text'></textarea>
    <label for='input_spamKey'>spamKey</label>
        <input type='text' id='input_spamKey' name='spamKey' />
    <input type='submit' value='Senden'>
</form>

script.js (using jQuery)

var spamKey = false;
$("#formOne > input").focus(function() {
         if(spamKey == false) {
        dataString = "action=getSpamKey";
        $.ajax({
            url: 'asyncresponse.php',
            data: dataString,
            type: "POST",
            success: function(data) {
                $("#input_spamKey").val(data);
                if(data != "") {
                    spamKey = true;
                }
              }
        });
    }
});

asyncresponse.php (Info: The POST-Variables are sanitized)

if($_POST["action"] == "getSpamKey") {
    $spamKey = md5(time().microtime());
    $_SESSION["spamKey"] = $spamKey;
    echo $spamKey;
}

check routine in PHP

($_SESSION["spamKey"] == $_POST["spamKey"] && !empty($_SESSION["spamKey"]))

Okay – whats my question?

Which steps you would suggest me to protect multiple forms? And probably a basic question – is this a valid solution to deal with the spam issue?

Thanks for your help in advance.

A simple demo you can find here:
http://godesign.ch/labor/antispam/index.php

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T23:54:27+00:00Added an answer on June 16, 2026 at 11:54 pm

    Captcha used to be an effective method of preventing spam. It is now broken because it was widely implemented, creating an economic incentive to break it (google “captcha broken”).

    I have seen this method be effective in projects. You risk that someone, at some point, will be motivated to break it. Correctly implemented, I believe it provides reasonable protection against spam at this point in time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Introduction: Now I know this question could be very broad and it would be
Introduction In a current project I'm working on we're using the ChartBoost SDK for
Introduction I have some sort of values that I might want to access several
Introduction : I have a repeater with linkbuttons, and when I click on some
Introduction I use Google Closure Compiler frequently for compressing my JavaScript files. Now, it
Some introduction: Hello, i wanted to ask, if there is an easy way, to
Introduction: I think Nape is a relatively new engine so some of you may
Introduction: I'm working on an API which provides access to Picasa, Flickr and some
Introduction When creating a new domain for Weblogic Portal 10.3.0.0, the following datasources are
Introduction I'm trying to emphase some region on a spherical surface saying that this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.