Voornaam
Achternaam:
Website:
Plaats:
Land:
<?php
// ---------- class definitie ----------
class cFormulier
{
    
// $aError is een array
    
var $aError = array();

    function 
setError($msg)
    {
        
$this->aError[]=$msg;
    } 
    
    function 
ControleVelden()
    {
        if (
count($this->aError) > 0)
        {
            return 
false;
        }
        return 
true;
    }    
    
    function 
errorWeergeven() 
    {
        if (
count($this->aError) == )
        {
            echo 
"<strong>U heeft het volgende veld niet ingevuld</strong><br />";
            foreach (
$this->aError as $this->value)
            {
                echo 
" - ".$this->value."<br />";
            }
        }
        else
        {
            echo 
"<strong>U heeft de volgende velden niet ingevuld</strong><br />";
            foreach (
$this->aError as $this->value)
            {
                echo 
" - ".$this->value."<br />";
            }
        }
    }
    
}

if ( 
$_SERVER['REQUEST_METHOD'] == 'POST' )
{
    
$oForm = new cFormulier(); // object aangemaakt
    
    // velden definiëren
    
if ( $_POST['sNaam'] ==""
    {
        
$oForm->setError('Naam invullen');
    }
    if ( 
$_POST['sAchternaam'] == "")
    {
        
$oForm->setError('Achternaam invullen');
    }
    if ( 
$_POST['sWebsite'] == "")
    {
        
$oForm->setError('Website invullen');
    }
    if ( 
$_POST['sWoonplaats'] == "")
    {
        
$oForm->setError('Woonplaats invullen');
    }
    if ( 
$_POST['sLand'] == "")
    {
        
$oForm->setError('Land invullen');
    }
    
/* controleren of er fouten zijn dmv van de functie controleVelden
    * 
    * Wanneer er fouten in zitten geeft die False zoniet TRUE
    */
    
    
if ( $oForm->controleVelden() !== TRUE )
    {
        
$oForm->errorWeergeven();
    }
    else
    {
          echo 
"bedankt voor uw interesse, u zult snel een feedback ontvangen";  
    }

}
else
{
    
?>
    <form method="post"  action="">
    <table cellpadding="0" cellspacing="3" border="0" style="width:350px;">
    <colgroup style="width:100px;"></colgroup>
    <colgroup style="width:250px;"></colgroup>
    <tbody>
        <tr>
            <td>
            Voornaam
            </td>
            <td>
             <input type="text" name="sNaam" value="" />
             </td>
        </tr>
        <tr>
            <td>
            Achternaam: 
            </td>
            <td>
             <input type="text" name="sAchternaam" value="" />
            </td>
        </tr>
        <tr>
            <td>
            Website: 
            </td>
            <td>
             <input type="text" name="sWebsite" value="" />
            </td>
        </tr>
        <tr>
            <td>
            Plaats: 
            </td>
            <td>
             <input type="text" name="sWoonplaats" value="" />
            </td>
        </tr>
        <tr>
            <td>
            Land: 
            </td>
            <td>
             <input type="text" name="sLand" value="" />
            </td>
        </tr>
        <tr>
            <td colspan="2">
            <input type="submit" name="submit" value="opslaan" />
            </td>
        </tr>
        </tbody>
        </table>
    </form>
    <?php
}

show_source(__FILE__);
?>