Sample> FormHook

<?php

// include TPLN
include('TPLN/TPLN.php');

$TPLN = new TPLN();

$TPLN->formSetLang('en');
$TPLN->formSetName('form'); // specify a form name

// change error display mode
if(!isset($_GET['display_mode']) || ($_GET['display_mode'] != 'T' && $_GET['display_mode'] != 'I'))
    
$TPLN->formSetDisplayMode('I');
else
    
$TPLN->formSetDisplayMode($_GET['display_mode']);

$TPLN->Open('formHook.html');

// rules
$TPLN->notEmpty('Firstname');
$TPLN->alphaNumeric('Firstname''_'); // only characters and _
$TPLN->notEmpty('FamilyName');
$TPLN->notEmpty('Email');
$TPLN->email('Email');

if(
$_POST)
    echo 
"Number of error in the form: ".$TPLN->formGetTotalError();

if(
$TPLN->formIsValid())
{
    
// your treatment here...
}

$TPLN->write();

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Form hook</title>
    <style type="text/css">
    <!--
    .form_error {color:red; font-weight: bold;}
    #formtab {background-color:#CCCCCC;}
    #formtab td {background-color:#fff;}
    #formtab th {background-color:#E5E5E5;font-weight:bold;text-align:left;}
    #formtab span {font-weight: bold;color: #FF0000;margin:0;padding:0;}
    -->
    </style>
    <link href="../style.css" rel="stylesheet" type="text/css" />
</head>

<body>

<h1>This example shows a method to customize error message</h1>


<!-- hide form error -->
<div class="form_error">
    <bloc::form_error>
        <strong>• {msg}</strong><br />
    </bloc::form_error>
</div>
<!-- hide form error -->

<form id="form" name="form" method="post" action="?display_mode={$_GET['display_mode']}">
<table cellpadding="3" cellspacing="1" id="formtab">
<tr>
    <th width="100" scope="row">Display error mode:  </th>
    <td>
        <input type="button" value="Top" onclick="alert('Display error mode changed to \'T\' please submit the form after the redirection');document.location.href='?display_mode=T';" />
        <input type="button" value="Inline" onclick="alert('Display error mode changed to \'I\' please submit the form after the redirection');document.location.href='?display_mode=I';" />
    </td>
</tr>

<tr>
    <th width="105" scope="row">Fistname</th>
    <td width="345">
          <input name="Firstname" type="text" id="Firstname" size="65" />
        <span id="error_Firstname"></span>
    </td>
</tr>

<tr>
    <th scope="row">FamilyName</th>
    <td>
        <input name="FamilyName" type="text" id="FamilyName" size="65" />
        <span id="error_FamilyName"></span>
    </td>
</tr>

<tr>
    <th scope="row">Email</th>
    <td>
        <input name="Email" type="text" id="Email" size="65" />
          <span id="error_Email"></span>
    </td>
</tr>


<tr>
    <td colspan="2" align="center" scope="row"><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
</form>

<bloc::form_valid>
<div id="form_valid">
Your form was submitted without errors !
And replaced by blocform_valid !
</div>
</bloc::form_valid>

<br />
<br />
{_Logo}<font size="1"> in {_Chrono} s<br>
Queries executed: {_QueryCount}</font>

</body>
</html>