Server Side Validation - $Error does not throw exception

Issues related to forms.
Post Reply
User avatar
Magical
 
 
Posts: 111
Joined: Thu Dec 14, 2017 5:08 pm
Contact:

Server Side Validation - $Error does not throw exception

Post by Magical »

Greetings,
Came across this issue with the generated php when server side validation is enabled. The $error variable seems to be evaluated after the mailto and so it never catches any error.

try {
if (!ValidateEmail($mailfrom))
{
$error .= "The specified email address (" . $mailfrom . ") is invalid!\n<br>";
throw new Exception($error);
}

if (empty($_POST['TextArea1']))
{
$error .= "Too many char\n<br>"; // NO THROW EXCEPTION HERE
}
if (strlen($_POST['TextArea1']) < 5)
{
$error .= "Too many char\n<br>";
}
if (strlen($_POST['TextArea1']) > 40)
{
$error .= "Too many char\n<br>"; //IF MORE THAN 40 CHARACTERS ENTERED THE CODE DOES NOTHING IT SENDS THE MAIL
}
$message .= $eol;
$message .= "IP Address : ";
$message .= $_SERVER['REMOTE_ADDR'];
$message .= $eol;
$message .= "Referer : ";
$message .= $_SERVER['SERVER_NAME'];
$message .= $_SERVER['PHP_SELF'];
$message .= $eol;

$body .= '--'.$boundary.'--'.$eol;
if ($mailto != '') THIS ONLY CHECKS IF THE MAILTO ADDRESS IS PRESENT IT SHOULD ALSO CHECK FOR IF $ERROR IS NOT EQUAL TO BLANK
{
mail($mailto, $subject, $body, $header); // MAIL IS SENT OVER HERE
}
header('Location: '.$success_url);
}
catch (Exception $e)
{
$errorcode = file_get_contents($error_url);
$replace = "##error##";
$errorcode = str_replace($replace, $e->getMessage(), $errorcode);
echo $errorcode;
}
exit;
}
?>
User avatar
Pablo
 
Posts: 21569
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Server Side Validation - $Error does not throw exception

Post by Pablo »

Thanks for the information!
This issue has addressed in the latest build (12/10/2019)
http://www.wysiwygwebbuilder.com/download.html
User avatar
Magical
 
 
Posts: 111
Joined: Thu Dec 14, 2017 5:08 pm
Contact:

Re: Server Side Validation - $Error does not throw exception

Post by Magical »

Thanks, so after I download this fix, do I just reopen each project and redeploy?
User avatar
Magical
 
 
Posts: 111
Joined: Thu Dec 14, 2017 5:08 pm
Contact:

Re: Server Side Validation - $Error does not throw exception

Post by Magical »

Tested it, works fine now! Thanks
Post Reply