The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
![]() |
reCaptcha clearing data. - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1) +--- Forum: Installation (https://forums.formtools.org/forumdisplay.php?fid=4) +--- Thread: reCaptcha clearing data. (/showthread.php?tid=1807) |
reCaptcha clearing data. - bwaye - Dec 10th, 2011 I am doing everything correct (apparently not). CODE: <?php irequire_once("../data/global/api/api.php"); ft_api_start_sessions(); $fields = isset($_SESSION["form_tools_form_data"]) ? ft_strip_tags($_SESSION["form_tools_form_data"]) : array(); $fields = ft_api_init_form_page(11); $params = array( "submit_button" => "Submit", "next_page" => "../thanks/index.php", "form_data" => $_POST, "file_data" => $_FILES, "finalize" => true ); ft_api_process_form($params); ?> SAMPLE FILEDS: <input type="text" name="phone" class="form_box" size="50" value="<?=@$fields["phone"]?>" /> <textarea name="message" cols="50" rows="3" ><?=@$fields["message"]?></textarea> RE: reCaptcha clearing data. - Ben - Dec 11th, 2011 Hi Bwaye, First off (while I remember it), a minor thing: move this line... PHP Code: $fields = isset($_SESSION["form_tools_form_data"]) ? ft_strip_tags($_SESSION["form_tools_form_data"]) : array(); ... after the ft_api_init_form_page() line. Otherwise it will always just set $fields to an empty array, then overwrite it with whatever's returned by ft_api_ini_form_page(). It won't have strip_tags run properly. Secondly, regarding your main question: what's happening is that your sessions aren't being cleared - it's just that it's not quite working as you'd expect. (I don't think this situation is actually documented, so don't feel bad...!) When you fill in the form & click submit, the form data is POSTed to the same page. The ft_api_init_form_page() line, which returns $fields, ONLY returns data that's already been stored in sessions. At this stage, the new content in the POST request hasn't been stored yet. The POST content is added to sessions later on in the ft_api_process_form() page. So what you need to do in this situation is detect for the situation where the form just failed the recaptcha, and update $fields to properly store the latest POST data. For that, try this code: PHP Code: <?php Hope this helps. [P.S. Stuff like this is why the Form Builder module is going to be such a saving grace. No more editing PHP code... yay!] RE: reCaptcha clearing data. - bwaye - Dec 11th, 2011 CORRECT - this did the trick // this is the new bit if (!empty($g_api_recaptcha_error)) { $fields = array_merge($fields, $_POST); } ----- THANKS - (Dec 11th, 2011, 10:54 AM)Ben Wrote: Hi Bwaye, |