Results 1 to 3 of 3

Thread: compare value of a user submitted field with pre-defined (hard coded) "answer"

  1. #1
    Join Date
    Sep 2013
    Posts
    3

    Question compare value of a user submitted field with pre-defined (hard coded) "answer"

    Hello,

    this is my first post here, please be gentle on me

    First of all, I am extremely happy with the way FormMail works, it is simply amazing and boasts with features! A big hurray to the developers of this great free coding!
    I have successfully set up everything including own error templates, and everything works as expected.

    As I am very inexperienced with php coding, I have a very silly question I can't wrap my mind around, so I figured asking:

    I am currently coding the contact-form for a the website of a band. Personally, I hate captcha whenever I need to use it, but I need to protect my form from excessive spamming. I would like to add a small security feature, which is similar to the text-captcha concept, but dumbed down a bit.

    I would like to have a specific field in my form, whose contents are checked before proceeding with the actual mailing of the form to the specified address.

    I imagine something like this, but lack the coding abilities to express myself accordingly:

    The html-form contains an extra field/imput declared like this:
    HTML Code:
    <label for="the_SPAMQUESTION">Anti-SPAM: Please type the name of this Band:</label>
    <input type="text" name="the_SPAMQUESTION" id="SPAMQUESTION" size="20"/>
    Visitors of my website are very likely to actually know the band-name of the band on whose website they are on, I figure it makes a good question with a simple answer.

    In the php section (aka. in the formmailer.php file) the script would then compare the contents of the submitted field something like this:

    PHP Code:
    get the contents of field"the_SPAMQUESTION"
    compare contents of the field with 3 possible answers (accounting for "all-lowercase""uppercase-then-lowercase" or "all-caps" writings of the bandnamei.e"bandname""Bandname""BANDNAME")
    - if 
    the content of field"the_SPAMQUESTION" matches one of these "answers" -->continue mailing me the actual form
    - else --> don't mail me, return the user to the form with the return-to-filled-out-form-link instead 
    Is something like this possible? Would I need to insert this into the formmailer.php file or rather the fmbadhandler.php file? Or should I rather out-source this into a different php file all together? If so, how do I pass along the values originally sent to formmailer.php into a different file? I am guessing it goes somewhere into the error-handling of fmbadhandler.php, as this also allows for feedback to the user in case they mess up...

    I would hate to have to resolve to javascript for this, as the whole website is currently pure css and html, so I am looking for a php solution, and am confident there is one.
    I am quite comfortable reading and writing code in general, but I just know nothing about php-syntax.

    Please help, or push me in the right direction?

  2. #2
    Join Date
    Sep 2013
    Posts
    3

    Exclamation Re: compare value of a user submitted field with pre-defined (hard coded) "answer"

    EDIT:

    In the meanwhile I have read up on the "conditions" tag that can be appended to the <imput> field, as soon as I had found the correct search-term. This forum is full of answers.

    This looks perfect for checking at least the plausibility of an email-address, but sadly still not suited for my problem, as all "hidden" fields are still visible to screen-readers, bots & crawlers alike.
    So, this makes me even more sure: I am looking for a solution that I can include in my php file.

  3. #3
    Join Date
    Sep 2013
    Posts
    3

    Thumbs up Re: compare value of a user submitted field with pre-defined (hard coded) "answer"

    For anyone wondering:

    In the end I resorted to solving it by using a condition which is "hidden" in the INI file, where it looks for a pattern which is actually only a truncated version of the desired "answer".

    In the INI I defined this condition:

    conditions5000 = ":##TEST#the_Question ~ /^a+n+s+w+e+r$/i #Anti-Spam, please answer the question correctly.#"

    (In english: "Test the field the_Qestion for an answer made of the following pattern: starts with letter A, followed by letter N which in turn must be followed by S, etc")

    And in the form simply used the above stated condition for this imput:

    <label for="the_Question"><strong>Please prove you are human by entering the answer to the question:</strong></label>
    <input type="text" name="the_Question" id="question"/>
    <input type="hidden" name="conditions5000" value="conditions5000" />

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Can a prefix be hard-coded into a text field?
    By rwilki in forum Community Support
    Replies: 1
    Last Post: 13-May-2011, 07:10 PM
  2. Replies: 1
    Last Post: 01-Aug-2008, 07:28 PM
  3. Please help with "subject" field being modified by user!!!!
    By steve02usa in forum Community Support
    Replies: 2
    Last Post: 13-Jun-2007, 07:41 PM
  4. Does "alert_to" form field use "AT_MANGLE" feature?
    By jennyp in forum Community Support
    Replies: 4
    Last Post: 05-Dec-2006, 11:29 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •