contactmail-formulier-anti-spam-en-mail-checker

Gesponsorde koppelingen

PHP script bestanden

  1. contactmail-formulier-anti-spam-en-mail-checker

« Lees de omschrijving en reacties

//------------------ contact.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
<?
//////////////////////////////////////////////////////////////
//    Contact / Mail formulier (Anti Spam & Mail Checker)     //
//                                                             //
//             Door: RdR^                                        //
//             E-mail: thijs [AT] ferket [DOT] net             //
//             Web:   http://www.ferket.net                    //
//                                                            //
//////////////////////////////////////////////////////////////


ob_start(); // Voor Cookie setten

// Headers zetten zodat de de inhoud niet word gecashed

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

// Config Gedeelte
$site = "http://www.jousite.nl";    // Site waarnaar je terug gaat als je een bericht hebt achtergelaten
$wm_naam = "Jou naam";                // Webmaster naam
$wm_email = "[email protected]";        // Webmaster E-mail
$Anti_Spam = "10";                    // Anti Spam Tijd in Minuten ( Voer "0" om de Spam Beveiliging uit te zetten )
$fout_text = TRUE;                    // Bij Fout Text Rood maken ( TRUE voor aan, FALSE voor uit )
$fout_vakje = TRUE;                    // Bij Fout Border om Vakje Rood maken ( TRUE voor aan, FALSE voor uit )
$html = TRUE;                        // Een HTML email


$ip = $_SERVER['REMOTE_ADDR'];        // IP van de verstuurder
$host = gethostbyaddr($ip);         // Host van verstuurder

// Mail Checker

function checkmail($email)
{

    $email_host = explode("@", $email);
    $email_host = $email_host[1];
    $email_resolved = gethostbyname($email_host);
    
    if($email_resolved == $email_host)
    {

        $valid = FALSE;
    }

    if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$",$email))
    {

        $valid = TRUE;
    }

    else
    {
        $valid = FALSE;
    }

    return $valid;
}


// kijken of het cookie bestaat, zoja dan wordt het formulier niet getoond.
if(!isset($_COOKIE['mailformulier']))
{

    if(isset($_POST['wis']))
    {

        foreach ($_POST as $key => $value)
        {

            unset($value);
        }

        header("Location: ".$_SERVER['PHP_SELF']."");
    }

    // Alles Controleren Wanneer er op Verzenden wordt gedrukt
    if(isset($_POST['verzenden']))
    {
        
        $naam = trim($_POST['naam']);
        $email = trim($_POST['email']);
        $onderwerp = trim($_POST['onderwerp']);
        $bericht = trim($_POST['bericht']);
        $fout = "";

        if($html)
        {

            // Headers
            $headers = "From: \"Contact Formulier\" <".$wm_email.">\r\n";
            $headers .= "Reply-To: \"".$naam."\" <".$email.">\n";
            $headers .= "Return-Path: Mail-Error <".$wm_email.">\n";
            $headers .= "MIME-Version: 1.0\n";
            $headers .= "Content-Transfer-Encoding: 8bit\n";
            $headers .= "Content-type: text/html; charset=iso-8859-1\n";
                
            // Bericht
            $message = "
            <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
            <html>
            <head>
            <style type=\"text/css\">
            body {
            border-right: 5px;
            border-top: 5px;
            border-left: 5px;
            border-bottom: 5px;
            font: 10px Verdana, Arial, Helvetica, sans-serif;
            }
            table {
            font: 10px Verdana, Arial, Helvetica, sans-serif;
            }
            table, a:link {
            color: #000;
            text-decoration: none;
            }
            table, a:visited {
            color: #000;
            text-decoration: none;
            }
            table, a:hover {
            color: #000;
            font-weight: bold;
            text-decoration: none;
            }
            </style>
            </head>
            
            <body>
            <br />
            <table>
            <tr><td>Naam:</td><td>"
.$naam."</td></tr>
            <tr><td>Email:</td><td><a href=\"mailto:"
.$email."\">".$email."</a></td></tr>
            <br />
            <tr><td>Bericht:</td><td>"
.$bericht."</td></tr>
            <tr><td colspan=\"2\">&nbsp;</td></tr>
            <br />
            <tr><td>Datum:</td><td>"
.date("d-m-Y H:i:s")."</td></tr>
            <tr><td>IP:</td><td><a href=\"http://sunny.nic.com/cgi-bin/whois?domain="
.$ip."\">".$ip."</a></td></tr>
            <tr><td>Host:</td><td>"
.$host."</td></tr>
            </table>
            
            </body>
            </html>"
;
            
        }

        else
        {
            $bericht_wrap = wordwrap ($bericht, 40, "\n", 1);
            // Headers
            $headers = "From: \"Contact Formulier\" <".$wm_naam.">\n";
            $headers .= "MIME-Version: 1.0\n";
            $headers .= "Content-type: text/plain; charset='iso-8859-1'\n";
        
            // Bericht
            $message = "Naam: ".$naam."        \n";
            $message .= "E-mail: ".$email."     \n";
            $message .= "Bericht:\n".$bericht_wrap."     \n ";
            $message .= "               \n ";
            $message .= "Datum: ".date("d-m-Y H:i:s")." \n";
            $message .= "------------------------------------------------------- \n ";
            $message .= "IP: ".$ip."                    \n ";
            $message .= "Host: ".$host."                \n ";
        
        }

        if((empty($naam)) OR (strlen($naam) < 3) OR (eregi("[<>]", $naam)))
        {

            $fout .= "U bent vergeten uw naam in te vullen! <br />";
            unset($naam);
            $fout_vakje_naam = "input_fout";
            $fout_text_naam = "text_fout";
        }

        if((empty($email)) OR (strlen($email) < 7) OR (eregi("[<>]", $email)))
        {

            $fout .= "U bent vergeten uw e-mail adres in te vullen! <br />";
            unset($email);
            $fout_vakje_email = "input_fout";
            $fout_text_email = "text_fout";
        }

        elseif(checkmail($email) == 0)
        {

            $fout .= "Vul een correct e-mail adres in! <br />";
            unset($email);
            $fout_vakje_email = "input_fout";
            $fout_text_email = "text_fout";
        }

        if((empty($onderwerp)) OR (strlen($onderwerp) < 3) OR (eregi(">", $onderwerp)) )
        {

            $fout .= "U bent vergeten een onderwerp in te vullen! <br />";
            unset($onderwerp);
            $fout_vakje_onderwerp = "input_fout";
            $fout_text_onderwerp = "text_fout";
        }

        if(empty($bericht))
        {

            $fout .= "U bent vergeten een bericht in te vullen! <br />";
            unset($bericht);
            $fout_vakje_bericht = "input_fout";
            $fout_text_bericht = "text_fout";
        }

        elseif(strlen($bericht) < 6)
        {

            $fout .= "Uw bericht is tekort! <br />";
            $fout_vakje_bericht = "input_fout";
            $fout_text_bericht = "text_fout";
        }

        if(!$fout_text)
        {

            unset($fout_text_naam);
            unset($fout_text_email);
            unset($fout_text_onderwerp);
            unset($fout_text_bericht);
        }

        if(!$fout_vakje)
        {

            unset($fout_vakje_naam);
            unset($fout_vakje_email);
            unset($fout_vakje_onderwerp);
            unset($fout_vakje_bericht);
        }

        if(!empty($fout))
        {

            echo "\n<p style=\"color:#FF0000;\">\n".$fout."<br />\n</p>\n"; // Weergeven van de fout(en)
        }
        else
        {
            mail($wm_email,$onderwerp,$message,$headers);
    
            // Bericht als mail succesvol is verzonden
            echo "<head><link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\"></head>";
            echo "<br /><p style=\"text-align: center;\">Uw contact bericht is succesvol verzonden!<br />";
            echo "Er word zo snel mogelijk gereageerd.<br /><br />";
            echo "Met vriendelijke groeten,<br />";
            echo "<b>".$wm_naam."</b></p>";
    
            // cookie zetten tegen spam
            setcookie("mailformulier",1,time()+($Anti_Spam*60));
    
            // formulier wordt niet weer getoond
            $Formulier = TRUE;
    
            header("refresh:3;url=".$site."");
        }
    }
}

else {
    $Formulier = FALSE;
    echo "<html><head><link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\" /></head><body>";
    echo "<p style=\"text-align: center;\"><h2> Spam Beveiliging </h2><br />";
    echo "U kunt maar eens in de $Anti_Spam minuten een e-mail versturen!</p></body></html>";
    header("refresh:3;url=".$site."");
}


if(!isset($Formulier))
{

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <link href="style.css" rel="stylesheet" type="text/css" />

  <title>Contact Formulier</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <!-- Created by Thijs      
  http://www.ferket.net -->
</head>

<body>
  <table class="tabel" border="1" cellpadding="5" cellspacing="0"  width="300">
        <tr>
            <td><br />
                 <form method="post" action="<? $_SERVER['PHP_SELF']; ?>">
                  <table>
                    <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="<? echo $fout_text_naam; ?>">Naam:</td>
                        <td><input type="text" class="<? echo $fout_vakje_naam; ?>" id="naam" name="naam" maxlength="20" value="<? if (!empty($naam)) { echo stripslashes($naam); } ?>" /></td>
                    </tr>
                    <tr>
                        <td class="<? echo $fout_text_email; ?>">Email:</td>
                        <td><input type="text" class="<? echo $fout_vakje_email; ?>" id="email" name="email" maxlength="30" value="<? if (!empty($email)) { echo $email; } ?>" /></td>
                    </tr>
                    <tr>
                        <td class="<? echo $fout_text_onderwerp; ?>">Onderwerp:</td>
                        <td><input type="text" class="<? echo $fout_vakje_onderwerp; ?>" id="onderwerp" name="onderwerp" maxlength="30" value="<? if (!empty($onderwerp)) { echo stripslashes($onderwerp); } ?>" /></td>
                    </tr>
                    <tr>
                        <td valign="top" class="<? echo $fout_text_bericht; ?>">Bericht:</td>
                        <td><textarea id="bericht" name="bericht" class="<? echo $fout_vakje_bericht; ?>" cols="35" rows="6"><? if (!empty($bericht)) { echo stripslashes($bericht); } ?></textarea></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td><input type="submit" id="verzenden" name="verzenden" value="Verzenden" /><input type="submit" id="wis" name="wis" value="Wis velden" /></td>
                    </tr>
                  </table>
                </form>
            </td>
        </tr>
  </table>    
</body>
</html>
<?
}
?>



//------------------ style.css ----------------//

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
68
69
70
body {
    border-right: 5px;
    border-top: 5px;
    border-left: 5px;
    border-bottom: 5px;
    font-size: 10px;
    font-family: Verdana, Arial, Helvetica, sans-serif;
}
table {
    font-size: 9px;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    background-color: #f2f4f7;
    border-color: #bac5d6;
}
input, textarea {
    background-color: #ffffff;
    border-style: solid;
    border-width: 1px;
    border-color: #bac5d6;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 10px;
    color: #000000;
}
select {
    background-color: #ffffff;
    border-style: solid;
    border-width: 1px;
    border-color: #bac5d6;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 10px;
    color: #000000;
}
a:link {
    color: #000000;
    text-decoration: none;
}
a:visited {
    color: #000000;
    text-decoration: none;
}
a:hover {
    color: #000000;
    font-weight: bold;
    text-decoration: none;
}
.input_fout {
    background-color: #ffffff;
    border-style: solid;
    border-width: 1px;
    border-color: #FF0000;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 10px;
    color: #000000;
}
.text_fout {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 10px;
    color: #FF0000;
}
.tabel {
    font-size: 9px;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    background-color: #f2f4f7;
    border-color: #bac5d6;
    margin: auto;
}
img {
    background-color: transparent;
    border: 0;
}

 
 

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.