formulier-velden-vergeten

Gesponsorde koppelingen

PHP script bestanden

  1. formulier-velden-vergeten

« Lees de omschrijving en reacties

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
67
<html>
<head>
<title>Velden vergeten</title>
<style type="text/css">
.forgotten {
    border: 1px solid #ff0000;
}
</style>
</head>
<body>
<?php
    //----- function to check required fields
    function CheckRequired($array)
    {

        //----- check if $array is not empty
        if (!empty($array))
        {

            //----- loop through the array and check if the value's been set
            foreach ($array as $value)
            {

                if (empty($_POST[$value]))
                    $form_error[] = $value;
            }
        }

        
        //--- return an array with missed fields
        return $form_error;
    }

    
    //----- check for required fields
    if ($_SERVER['REQUEST_METHOD'] == 'POST')
        $required_fields = CheckRequired(array('name', 'email', 'message'));

    //----- check if all required fields are entered
    if ($_SERVER['REQUEST_METHOD'] == 'POST' && empty($required_fields))
    {

        echo 'Verwerk formulier';
    }

    else
    {
        //----- if form's been posted before, there are some fields left undone
        if (!empty($required_fields))
        {

            $i = 1;
            foreach ($required_fields as $value)
            {

                // echo 'U forgot the field: ' . ucfirst($value) . '.<br />';
                $varname = 'class_' . $value;
                ${$varname} = 'class=forgotten';
                    
                $i++;
            }
        }

        
        //----- start form
        echo "<form method=\"POST\" action=\"" . $_SERVER['PHP_SELF'] . "\">";
        echo "<p>";
        echo "<input type=\"text\" name=\"name\" value=\"" . htmlentities($_POST['name']) . "\" " . $class_name . " /> Name<br />";
        echo "<input type=\"text\" name=\"email\" value=\"" . htmlentities($_POST['email']) . "\" " . $class_email . " /> E-mail adres<br />";
        echo "<textarea name=\"message\" rows=\"8\" cols=\"\" style=\"width: 400px\" " . $class_message . ">" . htmlentities($_POST['message']) . "</textarea><br />";
        echo "<input type=\"submit\" name=\"submit\" value=\" Versturen \" />";
        echo "</p>";
        echo "</form>";
    }

?>

</body>
</html>

 
 

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.