The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
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 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. - 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 |