The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
![]() |
Human Test Question : Pre-Parser Code not working ? - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Modules / Other (https://forums.formtools.org/forumdisplay.php?fid=8) +--- Forum: Modules (https://forums.formtools.org/forumdisplay.php?fid=16) +--- Thread: Human Test Question : Pre-Parser Code not working ? (/showthread.php?tid=2823) |
Human Test Question : Pre-Parser Code not working ? - ITZAP - Jan 25th, 2014 Using the very latest Form Builder v1.0.5, rather than use reCAPTCHA, I have a simple "Human Test Question" field ... What is TEN plus SIX ? Field name = "htest", number, Tiny <= 5 characters, Required. And in the Submission Pre-Parser, I have this code ... if ($_POST["htest"] !=16) $_POST["form_tools_ignore_submission"] = true; But this does not work. I can make a submission with any answer, other than 16, and the Form submission is accepted and data entered into the dbase. if ({$ANSWER_htest} !== "16") $_POST["form_tools_ignore_submission"] = true; Does not work either. What is wrong with my Pre-Parser code ? Any help very much appreciated ! Many thanks, Gary, I.T.ZAP. RE: Human Test Question : Pre-Parser Code not working ? - ITZAP - Jan 26th, 2014 Attempting to prevent Blank submissions from being added to the database using the Submission Pre-Parser using this PHP code ... if (empty($_POST["name"])) OR (empty($_POST["email"])) OR (empty($_POST["password"])) OR (empty($_POST["accuracy"])) $_POST["form_tools_ignore_submission"] = true; But I cannot get this to work at all. Paid for 2 installations of the Form Builder for complex forms on 2 websites. Any support in replying to this question much appreciated. RE: Human Test Question : Pre-Parser Code not working ? - Joe - Jan 27th, 2014 Hi Gary, The logic looks correct. Could you PM me your Form Tools login information? Cheers, Joe RE: Human Test Question : Pre-Parser Code not working ? - ITZAP - Jan 28th, 2014 PM sent, thanks Joe. RE: Human Test Question : Pre-Parser Code not working ? - Joe - Jan 29th, 2014 Hi Gary, Thanks for sending along your login credentials. We took a closer look through the code and found the issue. The Form Builder works by starting with a blank submission in the database, then as the user steps from page to page, it updates the DB record. So the Submission Pre-Parser rule needs to be set to be trigger "on edit", not the other (way more intuitive) "On submission" / "On submission (API)" since there is already an existing record. Also, it doesn't appear that the form_tools_ignore_submission key works for this particular form. We can't narrow down the particular issue. So instead, you can just change the rule to this: if (isset($_POST["htest"]) && $_POST["htest"] != "16") { header("location: http://www.google.com"); exit; } And you'll need to specify whatever redirect URL you want and that will automatically redirect bots to a different location. For the other requests please be aware that the pre-parser rules will fire every time the user goes from one page to the other. Accordingly, checking that $_POST has the desired key in it is paramount, otherwise it will fire all the time. Checking for the existence of a key will ensure it only fires on a single page. Cheers, Joe RE: Human Test Question : Pre-Parser Code not working ? - ITZAP - Jan 29th, 2014 (Jan 29th, 2014, 8:51 AM)Joe Wrote: Also, it doesn't appear that the form_tools_ignore_submission key works for this particular form. We can't narrow down the particular issue. Thanks Joe, that "exit with redirect" method does work. But for the other functions I need, like prevent Blank submissions if form abandoned and end total calculation, looks like I need to design an External Form pointed to process.php, rather than use the "Form Builder" module. Your assistance and support much appreciated. Gary, ITZAP. |