setting an error page in form generates error 500

Issues related to forms.
Post Reply
si458
 
 
Posts: 5
Joined: Wed Jul 21, 2021 12:16 pm

setting an error page in form generates error 500

Post by si458 » Wed Jul 21, 2021 12:25 pm

Hi All,

im not sure if its a bug or maybe something else, im using the latest version (16.4.1 64 bit)

if i DONT set a error page in a form, the submit form works fine,

however if i then set a custom error page, i get a HTTP ERROR 500,

the php is showing
PHP Warning: file_get_contents(smartlink://page00008): failed to open stream: No such file or directory in /var/www/vhosts/myserver.com/httpdocs/test/nominate.php on line 11', referer: https://www.myserver.com/test/nominate.php
after checking the code, it seems to be generating invalid smartlink in the php code, and even if changing the page to another page, the number changes but its still showing smartlink?
<?php
session_start();
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['formid'] == 'form1')
{
if (isset($_POST['captcha'], $_SESSION['captcha']) && md5($_POST['captcha']) == $_SESSION['captcha'])
{
unset($_POST['captcha'], $_SESSION['captcha']);
}
else
{
$errorcode = file_get_contents('smartlink://page00008');
$errorcode = str_replace('##error##', 'CAPTCHA verification failed.', $errorcode);
echo $errorcode;
exit;
}
}
?>
any help would be amazing!

Regards

Simon

User avatar
Pablo
 
Posts: 24259
Joined: Tue Mar 28, 2006 12:00 pm
Location: Europe
Contact:

Re: setting an error page in form generates error 500

Post by Pablo » Wed Jul 21, 2021 12:41 pm

It looks like you have set an invalid error page.

If you need further assistance then share a demo project so I can see all your settings.
Please read this before sharing a demo project:
viewtopic.php?f=10&t=82134

si458
 
 
Posts: 5
Joined: Wed Jul 21, 2021 12:16 pm

Re: setting an error page in form generates error 500

Post by si458 » Wed Jul 21, 2021 12:49 pm

Pablo wrote:
Wed Jul 21, 2021 12:41 pm
It looks like you have set an invalid error page.
thats the issue, i havent?

i right click the form, object properties, then success page and error page are set correctly

./nominate_success.html and ./nominate_error.html

ive even checked in the page html using the html option in the home menu

Image

and the generated code shows smartlink:// before i even publish my test website?

ive even tried changing the pages to other pages but it still generates an error

Image

si458
 
 
Posts: 5
Joined: Wed Jul 21, 2021 12:16 pm

Re: setting an error page in form generates error 500

Post by si458 » Wed Jul 21, 2021 12:56 pm

please find an example here - https://mega.nz/file/6KwkjBAT#Ngk1C69AQ ... E3d31lydOQ

its just got a 3 pages, main, success, error

on the main is the form

and if you check the generated HTML, that it also showing the smartlink:// instead of the correct page

User avatar
Pablo
 
Posts: 24259
Joined: Tue Mar 28, 2006 12:00 pm
Location: Europe
Contact:

Re: setting an error page in form generates error 500

Post by Pablo » Wed Jul 21, 2021 1:06 pm

Please check the properties of the Captcha object, the error page is not specified.

si458
 
 
Posts: 5
Joined: Wed Jul 21, 2021 12:16 pm

Re: setting an error page in form generates error 500

Post by si458 » Wed Jul 21, 2021 1:18 pm

Pablo wrote:
Wed Jul 21, 2021 1:06 pm
Please check the properties of the Captcha object, the error page is not specified.
ok that sets the page correctly, but it means yet another page im required to create to show the captcha error

i also think ive found a bug,

if you create a simple template but then add a captcha into during the wizard, and check the HTML,
it seems to ignore that line totally and not included, which is perfect and ideal!
<?php
session_start();
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['formid'] == 'form1')
{
if (isset($_POST['captcha'], $_SESSION['captcha']) && md5($_POST['captcha']) == $_SESSION['captcha'])
{
unset($_POST['captcha'], $_SESSION['captcha']);
}
else
{
echo '<strong>CAPTCHA verification failed.</strong><br>';
echo '<a href="javascript:history.back()">Go Back</a>';
exit;
}
}
?>
BUT if you set a FORM error page AND not a captcha error page, then smartlink error gets added?

but the captcha error page is blank on purpose to simply display the error above on the same page without creating yet another page

so surely this is a bug as it shouldnt of set this line at all?

also handy feature request - the ability to BLANK/CLEAR the text boxes out, in case i set them by mistake and i never wanted them in the first place

User avatar
Pablo
 
Posts: 24259
Joined: Tue Mar 28, 2006 12:00 pm
Location: Europe
Contact:

Re: setting an error page in form generates error 500

Post by Pablo » Wed Jul 21, 2021 1:22 pm

ok that sets the page correctly, but it means yet another page im required to create to show the captcha error
If you want, you can use the same error page as for the form.

If you leave the error page in the captcha empty then the value will be undefined. You must set a valid error page. The same is true for the success and error page in the form.
See also this related FAQ: "Can I leave the success and error field empty?"
viewtopic.php?f=10&t=32967
the ability to BLANK/CLEAR the text boxes out, in case i set them by mistake and i never wanted them in the first place
Do you mean clear the success and error page? In that case, should the shift key and click the 'Select' button.
However, as mentioned these fields should not be empty.

si458
 
 
Posts: 5
Joined: Wed Jul 21, 2021 12:16 pm

Re: setting an error page in form generates error 500

Post by si458 » Wed Jul 21, 2021 3:10 pm

thank you Pablo!
i created a single error page and used and ##error## and that works a treat!
i also found another way around and playing around,
i used the real-time validation so the form cannot be submitted until you enter the code right!
saves the error page completely!
thank you again!

Post Reply