Sample> FormIsValid

<?php

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

$TPLN = new TPLN();

$TPLN->dbConnect();
$TPLN->formSetLang('en');

// initialiaze record
$TPLN->doQuery("SELECT Name AS text, Code AS value FROM Country");
$options '';
while(
$row $TPLN->DBFetch())
    
$options .= "<option value=\"{$row['value']}\">{$row['text']}</option>\n";

// value selected ?
if(isset($_GET['Code']))
{
    
$sql "SELECT * FROM Country WHERE Code='".$TPLN->checkQuotes($_GET['Code'])."'";
    
$TPLN->doQuery($sql);
    
$row $TPLN->dbFetch();
    
$TPLN->formInit($row);
}

$TPLN->dbClose();


$TPLN->open('formIsValid.html');

//$TPLN->notEmpty(array('Continent', 'Region'));
$TPLN->notEmpty('Continent''Continent must be filled');
$TPLN->notEmpty('Region''Region must be filled');


// here one test if the form is valid or not, the parameter allows us to keep the data seized by the user
if($TPLN->formIsValid())
{
    
// treatment
    // bloc form_validate is displayed automatically

}
$TPLN->write();


?>
<html>
<head>
    <title>form is valid</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="../style.css" rel="stylesheet" type="text/css" />
</head>
<body>

<h1>Automatic initialize an html form directly by a php array</h1>

<form action="" method="post" name="form">
<table cellspacing="1" cellpadding="3" style="border:1px solid black; background-color:#FFFFFF;">
<tr>
    <td colspan="2" align="left" bgcolor="#CCCCCC">
    <select name="Code" id="Code" onChange="document.location.href='?Code='+this.value">

      <option value="">Choose your country</option>
        {$options}
    </select>
    </td>
</tr>


<tr>
    <td>Continent : </td>
    <td>
        <select name="Continent" id="Continent">
            <option value="">Please Select</option>
            <option value="Asia">Asia</option>
            <option value="Europe">Europe</option>
            <option value="North America">North America</option>
            <option value="Africa">Africa</option>
            <option value="Oceania">Oceania</option>
            <option value="Antarctica">Antarctica</option>
            <option value="South America">South America</option>
        </select>
    </td>
</tr>


<tr>
    <td>Region : </td>
    <td>
        <input type="text" name="Region" id="Region" value="">
    </td>
</tr>

<tr>
    <td colspan="2" align="center"><p>
        <input type="submit" value="   Send   ">
    </td>
</tr>
</table>
</form>

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

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