Green pop-up notification for success is random

For devs and testers: Tests of current development versions, technical details of the code.
Post Reply
andriishyichuk
Posts: 4
Joined: Tue Dec 10, 2024 12:28 pm

Green pop-up notification for success is random

Post by andriishyichuk » Wed Feb 26, 2025 2:15 pm

I have a form for conference registration which I made by a deep rebuild of the contact form.

The problem: the red error popups work well and always, while the green success pop-up shows up at random. Or rather, it seems to never show up if registration goes smoothly (with no errors) on the first try. Everything else works, and if there where errors - the next attempt does show the green pop-up.

The internal works in terms of function call structure is the same exact as in contact.php. Also, funnily enough, I think the original contact form also does this bug - I do not explicitly remember testing it though. I likely did?

Thus: what controls the pop-up? I do smarty->assign('success', 1) on success, and that does not work. Or rather, it does not work first time. I cannot pinpoint it by analysing the code, so - HALP.

Thank you

User avatar
fraenkiman
Posts: 311
Joined: Thu Feb 03, 2022 7:25 pm
Location: Berlin, Germany
Contact:

Re: Green pop-up notification for success is random

Post by fraenkiman » Thu Feb 27, 2025 8:23 pm

Hello andriishyichuk,

the contact form in its original form up to FlatPress 1.3.1 also has the problem that green success messages are not displayed. I have fixed this in FlatPress 1.4 CR1.
This error is particularly noticeable when caching mechanisms are active on the web server, for example APCu or OPcache.

Here you can find the changes that have fixed the problem.

Best regards
Frank
:pencil: You are strong in PHP and Java Script? :point_right: Then help us to improve FlatPress. :point_left:

:exploding_head: Looking for ideas, templates, examples and answers to frequently asked questions?
:bulb: You'll find it here.

My :de: FlatPress-Blog: https://frank-web.dedyn.io

andriishyichuk
Posts: 4
Joined: Tue Dec 10, 2024 12:28 pm

Re: Green pop-up notification for success is random

Post by andriishyichuk » Mon Mar 10, 2025 1:33 pm

I see, thank you.

Do I understand correctly that doing "$smarty->assign('success', 1);" and then 'system_seterr("contact", 1)' should do the trick? That's what I did and it's still random.

Which part of the code reads the variable set by '"system_seterr("contact", 1)'? Cuz, I named my form "regform" and hence the seterr part would read "system_seterr("regform", 1). Basically, is there a static lust of err variables that I must update?

User avatar
fraenkiman
Posts: 311
Joined: Thu Feb 03, 2022 7:25 pm
Location: Berlin, Germany
Contact:

Re: Green pop-up notification for success is random

Post by fraenkiman » Thu Mar 13, 2025 10:59 pm

Hello andriishyichuk.

The logic fits.
$success must result in 1. Then you assign the result 1 directly to the template and then with system_seterr into the session -> before a forwarding takes place.

Before you assign a result to the template, simply check one line above whether $success = utils_mail.... really returns 1. The success message depends on this. It is possible that sendmail or a similar program is acting up.

Code: Select all

$success = utils_mail....; // must return 1
echo '<pre>' . $success . '</pre>';
$smarty->assign('success', $success ? 1 : -1);
system_seterr('xyz', $success ? 1 : -1);
utils_redirect.....;
If you get stuck, throw everything into a ZIP archive and send it to me by e-mail.

Best regards
Frank
:pencil: You are strong in PHP and Java Script? :point_right: Then help us to improve FlatPress. :point_left:

:exploding_head: Looking for ideas, templates, examples and answers to frequently asked questions?
:bulb: You'll find it here.

My :de: FlatPress-Blog: https://frank-web.dedyn.io

andriishyichuk
Posts: 4
Joined: Tue Dec 10, 2024 12:28 pm

Re: Green pop-up notification for success is random

Post by andriishyichuk » Wed Mar 26, 2025 12:19 pm

Last time I did it, I just went with $smarty->assign('success', 1);
And yet it was random.
Anyway, today is the day I add another feature, and I will know more.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 22 guests