Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • James 251 posts 1169 karma points
    Sep 05, 2014 @ 14:58
    James
    0

    Some captcha for my form

    Hi guys,

     

    Can you confirm what i have done is sufficient to stop spam.

    When the page loads:

    @{

        Layout = "Layout.cshtml";

        int aNumber = new Random().Next(1, 3);

        int bNumber = new Random().Next(1, 11);

        var errorPrintOut = "";

        bool contactSent = false;

    }

     

    The numbers are displayed to the user to add:

    <label id="captchaCheckLabel" for="captchaCheck">@aNumber + @bNumber =</label><p style="color:red; font-size: 20px;">@errorPrintOut</p>

     <input type="hidden" name="nA" value="@aNumber" />

      <input type="hidden" name="nB" value="@bNumber" />

     

    The user submits the form and:

     

    @if (IsPost)

    {

        var capchaCheck = Request.Form["captchaCheck"].AsInt();

        var nA = Request.Form["nA"].AsInt();

        var nB = Request.Form["nB"].AsInt();

     

        if (capchaCheck == (nA + nB))

        {

            //send email

            contactSent = true;

        }

        else

        {

            errorPrintOut = "Sorry that was incorrect. Please try again.";

        }

    }

     

    In esence will this stop spam bots or not?

     

    Kind regards.

     

     

     

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies