formulier-class

Gesponsorde koppelingen

PHP script bestanden

  1. formulier-class

« Lees de omschrijving en reacties

--------- CSS --------------------

<style type="text/css">

.cssform p {
width: 300px;
clear: left;
padding: 5px 0 8px 0;
padding-left: 155px;
height: 1%;
}

.cssform label {
float: left;
margin-left: -155px;
}

</style>

-------------- PHP -----------------------

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php

class form
{    
    var
$start;
    var
$body;
    var
$end;
    var
$html;
    
    function
__construct($name = "Verstuur", $target, $method = "POST", $reset = false) {
        $id = strtolower(str_replace(' ', '_', $name));
        $this->start = "<form class='cssform' name='".$id."' action='".$target."' method='".$method."'>";
        $this->end .= "<p>";
        if ($reset) $this->end .= "<input type='reset' value='Stel opnieuw in' />";
        $this->end .= "<input type='submit' name='".$id."' value='".$name."' /></p>";
        $this->end .= "</form>";
        $this->html = $this->start . $this->end;
    }    
    
    function
input($type, $name, $value) {
        $id = strtolower(str_replace(' ', '_', $name));
        switch ($type) {        
        case
'text':
        case
'password':
            $this->body .= "<p><label for='".$id."'>".$name.": </label>";
            $this->body .= "<input type='".$type."' name='".$id."' id='".$id."' value='".$value."' /></p>";
            break;
        case
'hidden':
            $this->body .= "<input type='hidden' name='".$id."' id='".$id."' value='".$value."' />";
            break;
        case
'checkbox':
            $this->body .= "<p>";
            $this->body .= "<input type='checkbox' name='".$id."' id='".$id."' value='".$value."' /> ".$value."<br />";
            $this->body .= "</p>";
            break;
        case
'radio':
            $this->body .= "<p><label>".$name.": </label>";
            foreach ($value as $option) {
                $optionId = strtolower(str_replace(' ', '_', $option));
                $this->body .= "<input type='radio' name='".$id."' id='".$id."' value='".$optionId."' /> ".$option."<br />";
            }

            $this->body .= "</p>";
            break;
        case
'file':
            $this->body .= "<p><label for='".$id."'>".$name.": </label>";
            $this->body .= "<input type='file' name='".$id."' id='".$id."' value='Kies bestand' /></p>";            
            break;
        case
'select':
            $this->body .= "<p><label for='".$id."'>".$name.": </label>";
            $this->body .= "<select name='".$id."' id='".$id."'>";
            foreach ($value as $option) {
                $optionId = strtolower(str_replace(' ', '_', $option));
                $this->body .= "<option value='".$optionId."'>".$option."</option>";
            }

            $this->body .= "</select></p>";            
            break;
        case
'textarea':
            $this->body .= "<p><label for='".$id."'>".$name.": </label>";
            $this->body .= "<textarea name='".$id."' id='".$id."'>".$value."</textarea></p>";
            break;
        }

        $this->html = $this->start . $this->body . $this->end;
    }
}


?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.