The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $newpmmsg - Line: 40 - File: global.php(841) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/global.php(841) : eval()'d code 40 errorHandler->error
/global.php 841 eval
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 909 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5024 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 5024 errorHandler->error
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions.php 5044 is_member
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1370 fetch_forum_permissions
/printthread.php 76 forum_permissions
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



Form Tools
Sending the wrong data when using 2 forms - Printable Version

+- Form Tools (https://forums.formtools.org)
+-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1)
+--- Forum: API (https://forums.formtools.org/forumdisplay.php?fid=17)
+--- Thread: Sending the wrong data when using 2 forms (/showthread.php?tid=843)



Sending the wrong data when using 2 forms - Petran - Sep 12th, 2010

Hello,

I installed formtools with succes but having this strange issue.

On my site I use two forms; one on the page "aanvraag informatie" where a visitor can subscribe to receive information, and one on the page "inschrijving" where can be subscribed for joining a workshop.

Everything works as it should when you directly go to the right page an fill in the form. The data is saved right and also the right confirmationmail is send.

However, when a visitor first goes to one of the pages, then -without filling any field- decides he has to use the other form and goes there, the data is send wrong.

example: I visit : "inschrijving", decide i've got the wrong page and go to "aanvraag informatie". I fill in the form and send it. Then the data is send to "inschrijving" and also the confirmationmail from "inschrijving" is send.

I tried disabling the cache and several other things, but I can't solve it.

I hope you understand my problem and can help me with it.

Regards,
Petran


RE: Sending the wrong data when using 2 forms - Ben - Sep 12th, 2010

Hi Petran,

Ah, what's happening is that when you go to a form page, the API sets up sessions for that individual form. When you go to the NEXT form, the sessions are still remembered from the last one, and cause the problem you mentioned.

Interesting this problem hasn't been brought up before, actually...

What you need to do is empty the sessions cache when flipping between forms. I'd probably do it like this. Right after the require("/path/to/api.php"); line in each of your forms add this:

PHP Code:
// X should be the form ID of your form on each page
if (isset($_SESSION["form_tools_form"]["form_tools_form_id"]) && $_SESSION["form_tools_form"]["form_tools_form_id"] != X) {
  
ft_api_init_form_page(X);
  
ft_api_clear_sessions();


That checks to see if the form ID in memory is different from the current form, and if so, empties it. (Weirdly, the ft_api_init_form_page(X) function call is needed here: the ft_api_clear_sessions() function needs it to have been called beforehand. I plan on fixing this at some point).

After that, you'll already have your own ft_api_init_form_page() function (already in your form), which will re-initiate sessions - and everything should work smoothly.

I confess, I haven't tested this, but it should work fine... knock on wood. Smile

- Ben


RE: Sending the wrong data when using 2 forms - Petran - Sep 12th, 2010

It does work ...however.

The forms I mentioned earlier are one single-page form and the other is a multi-page form.

I inserted the code in both forms. It does work for the multi-page form, but not for the single-page one.

I tried to play around with your code and found that only adding ft_api_clear_sessions(); did work.

It seems a bit strange to me, but I'm not a programmer. I would appreciate if you could look at this again.

regards,
Petran