mailformhandler-v1
Code (php)
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
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
<?php
/***********************************************
* Author: Clear Webdesign
* Date: 1 - 12 - 2004
* Script: Formhandler
* Version: 1.0.0
***********************************************/
/***********************************************
* Noting in this script has te be modified
* to be functional. The only thing this script
* needs is a data feed from forms.
************************************************/
class formhandler{
var $PostVars;
function formhandler($restricted){
$PostRestricted = explode(";", $restricted);
$EmailContents = array(
'Subject' => $_POST['subject'],
'To' => $_POST['email_adress_to'],
'Header' => "Er is een formulier ingevuld, hieronder de gegevens:<hr><p>",
'Content' => "",
'Footer' => "<font size=-2>Deze email is automatisch gegenereerd. Als er fouten zijn,
neem dan contact op met [email protected] <br>Bedankt!</font>",
'EmailHeaders' => "Content-Type: text/html; charset=iso-8859-1 \r\n "
);
unset($_POST['subject'], $_POST['email_adress_to']);
/*******************************
* Loops ******************/
foreach($_POST as $PostNaam => $PostWaarde){
foreach($PostRestricted as $PostRestrictedNr => $PostRestrictedNaam){
if(($PostNaam == $PostRestrictedNaam) && empty($_POST[$PostNaam])){
$this->notfilled($PostNaam);
}
}
}
unset($_POST['restricted']);
unset($_POST['submit']);
$this->sendform($EmailContents);
}
function notfilled($field){
die("U heeft het veld <strong> \"" . ucfirst(strtolower($field)) . "\"</strong> niet ingevuld. Ga terug en vul die veld vervolgens in");
}
function sendform($EmailContents){
foreach($_POST as $PostNaam => $PostWaarde){
$EmailContents['Content'] .= "<strong>" . $PostNaam . "</strong>: " . $PostWaarde . "<br>";
}
$Mail = mail(
$EmailContents['To'],
$EmailContents['Subject'],
$EmailContents['Header'] . $EmailContents['Content'] . $EmailContent['Footer'],
$EmailContents['EmailHeaders']
);
if(!$Mail){
die("De mail kon niet worden verzonden. Neem contact op met de webmaster. Sorry voor het ongemak!");
}
// Error_reporting
error_reporting(E_ALL);
}
}$do = new formhandler($_POST['restricted']);
?>
/***********************************************
* Author: Clear Webdesign
* Date: 1 - 12 - 2004
* Script: Formhandler
* Version: 1.0.0
***********************************************/
/***********************************************
* Noting in this script has te be modified
* to be functional. The only thing this script
* needs is a data feed from forms.
************************************************/
class formhandler{
var $PostVars;
function formhandler($restricted){
$PostRestricted = explode(";", $restricted);
$EmailContents = array(
'Subject' => $_POST['subject'],
'To' => $_POST['email_adress_to'],
'Header' => "Er is een formulier ingevuld, hieronder de gegevens:<hr><p>",
'Content' => "",
'Footer' => "<font size=-2>Deze email is automatisch gegenereerd. Als er fouten zijn,
neem dan contact op met [email protected] <br>Bedankt!</font>",
'EmailHeaders' => "Content-Type: text/html; charset=iso-8859-1 \r\n "
);
unset($_POST['subject'], $_POST['email_adress_to']);
/*******************************
* Loops ******************/
foreach($_POST as $PostNaam => $PostWaarde){
foreach($PostRestricted as $PostRestrictedNr => $PostRestrictedNaam){
if(($PostNaam == $PostRestrictedNaam) && empty($_POST[$PostNaam])){
$this->notfilled($PostNaam);
}
}
}
unset($_POST['restricted']);
unset($_POST['submit']);
$this->sendform($EmailContents);
}
function notfilled($field){
die("U heeft het veld <strong> \"" . ucfirst(strtolower($field)) . "\"</strong> niet ingevuld. Ga terug en vul die veld vervolgens in");
}
function sendform($EmailContents){
foreach($_POST as $PostNaam => $PostWaarde){
$EmailContents['Content'] .= "<strong>" . $PostNaam . "</strong>: " . $PostWaarde . "<br>";
}
$Mail = mail(
$EmailContents['To'],
$EmailContents['Subject'],
$EmailContents['Header'] . $EmailContents['Content'] . $EmailContent['Footer'],
$EmailContents['EmailHeaders']
);
if(!$Mail){
die("De mail kon niet worden verzonden. Neem contact op met de webmaster. Sorry voor het ongemak!");
}
// Error_reporting
error_reporting(E_ALL);
}
}$do = new formhandler($_POST['restricted']);
?>