Developer Support »

Customizing error messages

By default the script will produce any error messages on a blank page with the messages shown in plain text (with the Pro script you can show error messages on the same page as the form). Try the demo forms (one on the "Free Version" page, one on the "Pro Version" page) to see this. If you would prefer these messages to be displayed in the style of your site, or within your own page structure, then you can edit the script to customize these, ideally calling your stylesheet.

To do so, locate this line in the script (from Pro version 3.3):

if(count($errors) && $show_errors_on_form_page == 0){foreach($errors as $value){print stripslashes($value) . "<br>";} exit;}

...or this line in the Free script (or Pro script prior to version 3.3)

if(count($errors)){foreach($errors as $value){print "$value<br>";} exit;}

You can precede the errors with any HTML and call a stylesheet. Lets say you want to incorporate a stylesheet, you could do something like this (replacing the above line with the code below):

if(count($errors))

{

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Error page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="/style.css">
</head>
<body>

<?php

foreach($errors as $value){print stripslashes($value) . "<br>";}

?>

</body>
</html>

<?php

exit;

}

Remember to enter the correct name and location for your stylesheet.

Alternatively you might want to include an existing header and footer, using this code instead:

if(count($errors))

{

include("header.php");

foreach($errors as $value){print stripslashes($value) . "<br>";}

include("footer.php");

exit;

}