Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Help with contact form class update

  1. #1
    Join Date
    Feb 2017
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Help with contact form class update

    I'm having trouble updating my cform class, which you built for me a few years back, to reflect the change from President Obama to President Trump as one of the Anti-Spam questions. I changed "Who is the current U.S. President?" => array ("Obama","obama","Barak Obama","Barak H. Obama","Barak Hussein Obama","Barack Hussein Obama II")
    // etc. ...

    to:

    "Who is the current U.S. President?" => array ("Trump","Donald Trump","Donald J. Trump","Donald John Trump")
    // etc. ...

    but it doesn't work. It has been some time since I messed with the coding here and am obviously missing something else, but what?

    Thanks in advance.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    That looks like PHP. Is it?

    In any case, with any programming language syntax is very important. A misplaced or missing comma, colon, quote mark, etc. can mess up a little or a lot. Using a word processor to edit instead of a text only editor can introduce erroneous characters. No way to be sure what the problem is from the little you've shown us here.
    Last edited by jscheuer1; 02-10-2017 at 12:10 PM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    Michael-D (02-10-2017)

  4. #3
    Join Date
    Feb 2017
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the reply.

    Yes, it's PHP.

    I use Adobe Dreamweaver and/or Noted ++, which were both used in the construction/editing of the site and form.

    If you could tell me what more is needed to be shown I'll post it. I am unsure how much is unsafe however as the coding was not created by me and I was warned about security of not keeping the coding guarded. The coding for these forms is outside my knowledge and CSS is the upper limit for me.

  5. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    It's true you shouldn't share your server side code if it shows vulnerabilities. But you code shouldn't be vulnerable to begin with, though sometimes thats hard to avoid, and keeping it hidden makes it safer. So, if we have to, we can have you email me the code. But let's first see if we can fix it without going through that.

    Let's try the simplest easiest thing to miss first. At the end of a line of PHP there should be a terminus, a semi-colon unless you're at the end of a closure of curly brackets indicating a loop or conditional, in the middle of a string literal that includes the line break, or using a comma to indicate a continuation of some list of definitions within a larger definition. Without that you get an error. What you have there looks like a definition, so might need a semi-colon. These semi-colons must come before comments. So:

    PHP Code:
    "Who is the current U.S. President?" => array ("Trump","Donald Trump","Donald J. Trump","Donald John Trump"// etc. ... 
    would maybe be:

    PHP Code:
    "Who is the current U.S. President?" => array ("Trump","Donald Trump","Donald J. Trump","Donald John Trump"); // etc. ... 
    Maybe, but I don't think so, using => most likely means you're defining the array of names ("Who is the current U.S. President?) as a part of a larger array, so it probably needs to be a comma:

    PHP Code:
    "Who is the current U.S. President?" => array ("Trump","Donald Trump","Donald J. Trump","Donald John Trump"), // etc. ... 
    separating it from the next definition in the overall array. But it needs something. It can't just end with the ) there. I'd go for the comma first and see if that fixes it.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. The Following User Says Thank You to jscheuer1 For This Useful Post:

    Michael-D (02-14-2017)

  7. #5
    Join Date
    Feb 2017
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Hi John,

    Thanks again for replying.

    You are correct that there is a definition of an array of questions in a question answer map of anti-spam challenges. There are four questions in total with the last two being:

    "What is 5-4?" => array ("1","One","one"),
    "Who is the current U.S. President?" => array ("Obama","obama","Barak Obama","Barak H. Obama","Barak Hussein Obama","Barack Hussein Obama II")
    // etc. ...
    );

    The one that has Obama as President, and is working, is on my server as above. There is no comma or semi-colon except after the // etc. …) The only difference between the one working, and the Trump version, which doesn’t work, is that for the working version the President question has six options and for the one that doesn’t work there are four. I do not see anything in the coding that relates to how many options there can be per question, so I doubt this is the issue, unless there is a .PHP or CSS file somewhere that is an include that I've forgotten about and needs tweaking too to reflect the change.

    Regards,

    Michael

  8. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well, it's correct that the last item in an array needs no terminus (comma in this case). But it can have one. However, if what you say is true, the most likely answer is that you're using something in the trump one that breaks it. Most often this is a missed internal comma or missing " mark or the use of a word processing quotes like or which lean instead of the straight up and down quote mark ". From what you posted, none of that looks wrong, but I may have missed it, or you may have posted something slightly different than what you have. It wouldn't cause any security issues to post the entire array by cutting and pasting it from your code. That way I could tell those things for sure. If all of that checks out, it must be the number of entries. Try repeating some of the trump ones so that it totals the same as the obama ones did. Or maybe just change the question to:

    PHP Code:
    "Who was the first black U.S. President?" => array ("Obama","obama","Barak Obama","Barak H. Obama","Barak Hussein Obama","Barack Hussein Obama II"
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. The Following User Says Thank You to jscheuer1 For This Useful Post:

    Michael-D (02-14-2017)

  10. #7
    Join Date
    Jan 2015
    Posts
    78
    Thanks
    0
    Thanked 19 Times in 19 Posts

    Default

    I'm wondering what "it doesn't work" looks like for this code? Are you getting a message that the captcha value is incorrect, even when one of the possible answers has been entered, or are you getting some other symptom or error? A php syntax error would either produce a blank page/http 500 error response or a php syntax error, depending on php's error related settings.

    I'm also wondering what a "cform class" is, and is part of, since it will be nearly impossible to solve a problem with any code, unless allowing an infinite amount of time, without knowing what exactly the complete code is that reproduces the problem.

    Also, text based question/answer captchas, regardless of how many different questions have been defined, are easy to solve, except by the simplest of bots, in which case it is just as effective to use a 'honey pot' captcha (a form field hidden by css that must be empty in the submitted data). All anyone needs to do is enter one of the questions and answers into a bot script, then just keep requesting the page until they get that specific question.

  11. #8
    Join Date
    Feb 2017
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Hi John,

    I've worked with this to try to get the "Trump" array to work, and no luck. I've taken your advice and changed the question to "Who was the first black U.S. President?" Thankfully, no issues.

    Traq designed this for me and put in all the safety features. The guy is brilliant and talked way over my head most of the time. He and another chap gave me a crash course in CSS as well so I could bring my web site up to par. Hopefully traq will see this, or my post seeking to hire him for a bit of a rework, and enlighten me on what I'm missing.

    Grateful for your input and at least the question is such that no error will occur given a new person sits in the White House.

  12. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well let's hope you get it worked out, because people won't remember forever who Obama was. Even asking the for the current US president is a little unfair for folks living in other countries, or anywhere, who might not be at all into politics.

    I did say one thing (that I know of) in this that might be wrong. Just because the new array you wanted is syntactically correct, I assumed it has to be the number of entries. That's a good guess on my part, but there could always be some other issue or combination of issues including or not including that.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  13. #10
    Join Date
    Feb 2017
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    Well let's hope you get it worked out, because people won't remember forever who Obama was. Even asking the for the current US president is a little unfair for folks living in other countries, or anywhere, who might not be at all into politics.
    Given that my site is regarding maritime history, and has people from the U.S., the U.K., Australia, and other countries, there's no way to be "fair" unless I rotate the question to include monarchs, prime ministers, etc., and I don't want to put that much effort into a simple anti-spam question. I think most people, at least those I would wish to deal with, are of a certain education level that they know the main world political figures, and as most perceive the U.S. to be at the top of the heap, I think most will remember who Obama was. It was simply a "fill" question and not political in nature as I lost interest in politics decades ago. Politics are for two types of fools; those who run for office and those who vote for them, regardless of political affiliation. I personally would like to forget ALL the U.S. Presidents post Reagan, and a number of world leaders globally, but the people mumbled and elected the long stream of disappointments on that list, including the present clown sitting in the White House. It would be nice if there was actually candidates to choose from, but when you draw from a cesspool, you can't expect to pull out anything but waste. It was entertaining seeing the circus act of candidates lined up and perpetually lying through their eye teeth and the coast to coast dullards eating it up like any of it was meaningful and/or worth listening to.

    I'm not expecting my site to run but a few more years as I'm wanting to walk away from the field of ships. I've been in it for nearly 50 years. I think that for the next few years people will recall who Obama was, and if they don't they would likely struggle with the other questions of "How many Apples in a dozen", "what is 5 - 4?", etc.

    I did say one thing (that I know of) in this that might be wrong. Just because the new array you wanted is syntactically correct, I assumed it has to be the number of entries. That's a good guess on my part, but there could always be some other issue or combination of issues including or not including that.
    I too wondered if it is the number of entries, but I can't find anything that would limit/specify that for any or all of the questions. That I cannot means nothing of course as I'm very likely overlooking it, not looking in the right place, or have no idea what I'm looking for.

Similar Threads

  1. PHP Contact Form
    By DS928 in forum PHP
    Replies: 1
    Last Post: 03-05-2014, 02:42 AM
  2. CSS Contact form-help need
    By bogdancornel in forum CSS
    Replies: 0
    Last Post: 06-22-2010, 03:17 PM
  3. Contact form
    By andyg41 in forum PHP
    Replies: 3
    Last Post: 08-02-2009, 08:47 PM
  4. Need Contact form...
    By baldrn in forum JavaScript
    Replies: 2
    Last Post: 04-14-2009, 03:26 PM
  5. Contact form using php
    By biomike in forum PHP
    Replies: 13
    Last Post: 12-26-2008, 03:25 AM

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
  •