Page 1 of 1

Green pop-up notification for success is random

Posted: Wed Feb 26, 2025 2:15 pm
by andriishyichuk
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

Re: Green pop-up notification for success is random

Posted: Thu Feb 27, 2025 8:23 pm
by fraenkiman
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

Re: Green pop-up notification for success is random

Posted: Mon Mar 10, 2025 1:33 pm
by andriishyichuk
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?

Re: Green pop-up notification for success is random

Posted: Thu Mar 13, 2025 10:59 pm
by fraenkiman
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

Re: Green pop-up notification for success is random

Posted: Wed Mar 26, 2025 12:19 pm
by andriishyichuk
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.