Contact formulier php
Ik heb een goed script voor een contact formulier, werkt als een trein. Alleen zou ik graag zien dat de verzendbevestiging geopend wordt in de layout van mijn site.
Nu krijg ik na het invullen van het formulier een blanco scherm met wat tekst erin. Het formulier staat op: www.pukt.nl
Misschien dat iemand mij kan helpen? Alvast bedankt!
script:
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
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
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
<?
$your_email_address="[email protected]";
if(empty($_GET) && empty($_POST)) {
die('Ongeldige actie');
}
// Emular register_globals on
if (!ini_get('register_globals')) {
$superglobales = array($_SERVER, $_ENV, $_FILES, $_COOKIE, $_POST, $_GET);
if (isset($_SESSION)) {
array_unshift($superglobales, $_SESSION);
}
foreach ($superglobales as $superglobal) {
extract($superglobal, EXTR_SKIP);
}
}
// to prevent header injection
if (eregi("\r",$_POST['your_email_address']) || eregi("\n",$_POST['your_email_address'])){
exit;
}
// kick anyone whoever tried to inject a header in the form
foreach( $_POST as $value ){
if( strpos($value,'Content-Type:') !== FALSE ){
exit;
}
}
$fields = array_keys($_POST);
function headfunction($url) {
header ("Location: $url");
}
// protect the variable $reserved_vars
if(isset($reserved_vars)) {
unset($reserved_vars);
}
$reserved_vars = array("css_file", "background_color", "background_image", "text_color", "link_color", "visited_link_color", "active_link_color", "font_name", "font_size", "highlight_color", "required_fields", "after_url", "check_email_address", "subject", "your_email_address", "env_report", "owner_name", "autoresponse", "response_subject", "response_mail", "dodosmail_header_file", "dodosmail_footer_file");
function include_dodosmail_header($dodosmail_header_file) {
global $reserved_vars;
foreach($reserved_vars as $reserved_var) {
global $$reserved_var;
}
if(is_file($dodosmail_header_file)) {
include_once($dodosmail_header_file);
return;
} else {
echo "<html>\n";
echo "<head>\n";
echo "<title>\n";
echo "DodosMail\n";
echo "</title>\n";
if($css_file != "")
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$css_file\">\n";
echo "</head>\n";
echo "<body bgcolor=\"$background_color\" background=\"$background_image\" text=\"$text_color\" link=\"$link_color\" vlink=\"$visited_link_color\" alink=\"$active_link_color\">\n";
echo "<font face=\"$font_name\" size=\"$font_size\">\n";
}
}
function include_dodosmail_footer($dodosmail_footer_file) {
global $reserved_vars;
foreach($reserved_vars as $reserved_var) {
global $$reserved_var;
}
if(is_file($dodosmail_footer_file)) {
include_once($dodosmail_footer_file);
return;
} else {
echo "</font>\n</body>\n</html>";
}
}
function dodosmail_error_handle($msg) {
global $highlight_color;
if(isset($highlight_color)) {
$extra_begin = "<font color=\"".$highlight_color."\">";
$extra_end = "</font>";
} else {
$extra_begin = "<span class=\"DodosMailErrorHighLight\">";
$extra_end = "</span>";
}
return $extra_begin.$msg.$extra_end;
}
// checking required fields
// in case they used comma and space, replace
if(strstr($required_fields, ", ")) {
$required_fields = str_replace(", ", ",", $required_fields);
} else {
$required_fields = $required_fields;
}
$required_fields = explode(",", $required_fields);
for($i = 0; $i < count($required_fields); $i++) {
$required_var_name = $required_fields[$i];
if(empty($$required_var_name)) {
include_dodosmail_header($dodosmail_header_file);
echo "<p class=\"DodosMailError\">U bent vergeten het verplichte veld ".dodosmail_error_handle($required_var_name)." in te vullen. Klik op terug om het formulier correct in te vullen en nogmaals te verzenden.\n";
echo "<br /><br /><a href=\"javascript:history.back(1)\">Terug</a>\n";
echo "</p>\n";
include_dodosmail_footer($dodosmail_footer_file);
exit;
}
}
if($check_email_address == "yes" && !empty($email)) {
if(!check_email($email)) {
include_dodosmail_header($dodosmail_header_file);
echo "<p class=\"DodosMailError\">Fout - het adres ".dodosmail_error_handle($email)." is niet geldig.\n";
echo "<br /><br /><a href=\"javascript:history.back(1)\">Terug</a>\n";
echo "</p>\n";
include_dodosmail_footer($dodosmail_footer_file);
exit;
}
}
for($i = 0; $i < count($fields); $i++) {
$actual_var = $fields[$i];
if(in_array($actual_var, $reserved_vars)) {
$inside_mail = $inside_mail;
} else {
if(is_array($$actual_var)) {
$inside_mail.= "$actual_var: ";
foreach($$actual_var as $actual_val) {
$inside_mail.= "$actual_val ";
}
$inside_mail.= "\n";
} else {
$actual_val = stripslashes($$actual_var);
$inside_mail.= "$actual_var: $actual_val\n";
}
}
}
// getting other information from the form
$cname = gethostbyaddr($_SERVER[REMOTE_ADDR]);
$inside_mail.=
"
-----------------------------------------------------------------------
SENDER INFO:
IP: $_SERVER[REMOTE_ADDR]
Computer Name: $cname
Browser Type: $_SERVER[HTTP_USER_AGENT]
Page Referer: $_SERVER[HTTP_REFERER]
-----------------------------------------------------------------------
";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-MSMail-Priority: Normal\r\n";
$headers .= "X-Mailer: DodosMail 2.0 http://regretless.com/scripts/\r\n";
$headers .= "Content-type: text/plain; charset=\"iso-8859-1\"\r\n";
//$headers .= "Date: ".date("R")."\r\n";
$headers .= "From: $name <$email>\r\n";
$success = mail($your_email_address, $subject, $inside_mail, $headers);
if($success) {
if($autoresponse == "yes") {
$response_subject = stripslashes($response_subject);
$response_mail = stripslashes($response_mail);
mail($email, $response_subject, $response_mail, "From: $owner_name <$your_email_address>");
}
if($after_url == "") {
// out put send info
include_dodosmail_header($dodosmail_header_file);
echo "<p>\n";
echo "Het formulier is verzonden!</p><ul>";
for($i = 0; $i < count($fields); $i++) {
$actual_var = $fields[$i];
if(in_array($actual_var, $reserved_vars))
echo "";
else {
if(is_array($$actual_var)) {
echo "<li>$actual_var: ";
foreach($$actual_var as $actual_val) {
echo "$actual_val ";
}
echo "</li>\n";
} else {
$actual_val = stripslashes($$actual_var);
echo "<li>$actual_var: $actual_val</li>\n";
}
}
}
echo "</ul>\n<p></p>";
include_dodosmail_footer($dodosmail_footer_file);
exit;
} else {
headfunction($after_url);
}
} else {
include_dodosmail_header($dodosmail_header_file);
echo "<p class=\"DodosMailError\">Fout - Het formulier is tijdelijk niet bruikbaar, gebruik ".dodosmail_error_handle($your_email_address)." om contact op te nemen.\n";
echo "<br /><br /><a href=\"javascript:history.back(1)\">Terug</a>\n";
echo "</p>\n";
include_dodosmail_footer($dodosmail_footer_file);
exit;
}
function check_email($email) {
if( (preg_match('/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/', $email)) ||
(preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/',$email)) ) {
return true;
}
return false;
}
?>
$your_email_address="[email protected]";
if(empty($_GET) && empty($_POST)) {
die('Ongeldige actie');
}
// Emular register_globals on
if (!ini_get('register_globals')) {
$superglobales = array($_SERVER, $_ENV, $_FILES, $_COOKIE, $_POST, $_GET);
if (isset($_SESSION)) {
array_unshift($superglobales, $_SESSION);
}
foreach ($superglobales as $superglobal) {
extract($superglobal, EXTR_SKIP);
}
}
// to prevent header injection
if (eregi("\r",$_POST['your_email_address']) || eregi("\n",$_POST['your_email_address'])){
exit;
}
// kick anyone whoever tried to inject a header in the form
foreach( $_POST as $value ){
if( strpos($value,'Content-Type:') !== FALSE ){
exit;
}
}
$fields = array_keys($_POST);
function headfunction($url) {
header ("Location: $url");
}
// protect the variable $reserved_vars
if(isset($reserved_vars)) {
unset($reserved_vars);
}
$reserved_vars = array("css_file", "background_color", "background_image", "text_color", "link_color", "visited_link_color", "active_link_color", "font_name", "font_size", "highlight_color", "required_fields", "after_url", "check_email_address", "subject", "your_email_address", "env_report", "owner_name", "autoresponse", "response_subject", "response_mail", "dodosmail_header_file", "dodosmail_footer_file");
function include_dodosmail_header($dodosmail_header_file) {
global $reserved_vars;
foreach($reserved_vars as $reserved_var) {
global $$reserved_var;
}
if(is_file($dodosmail_header_file)) {
include_once($dodosmail_header_file);
return;
} else {
echo "<html>\n";
echo "<head>\n";
echo "<title>\n";
echo "DodosMail\n";
echo "</title>\n";
if($css_file != "")
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$css_file\">\n";
echo "</head>\n";
echo "<body bgcolor=\"$background_color\" background=\"$background_image\" text=\"$text_color\" link=\"$link_color\" vlink=\"$visited_link_color\" alink=\"$active_link_color\">\n";
echo "<font face=\"$font_name\" size=\"$font_size\">\n";
}
}
function include_dodosmail_footer($dodosmail_footer_file) {
global $reserved_vars;
foreach($reserved_vars as $reserved_var) {
global $$reserved_var;
}
if(is_file($dodosmail_footer_file)) {
include_once($dodosmail_footer_file);
return;
} else {
echo "</font>\n</body>\n</html>";
}
}
function dodosmail_error_handle($msg) {
global $highlight_color;
if(isset($highlight_color)) {
$extra_begin = "<font color=\"".$highlight_color."\">";
$extra_end = "</font>";
} else {
$extra_begin = "<span class=\"DodosMailErrorHighLight\">";
$extra_end = "</span>";
}
return $extra_begin.$msg.$extra_end;
}
// checking required fields
// in case they used comma and space, replace
if(strstr($required_fields, ", ")) {
$required_fields = str_replace(", ", ",", $required_fields);
} else {
$required_fields = $required_fields;
}
$required_fields = explode(",", $required_fields);
for($i = 0; $i < count($required_fields); $i++) {
$required_var_name = $required_fields[$i];
if(empty($$required_var_name)) {
include_dodosmail_header($dodosmail_header_file);
echo "<p class=\"DodosMailError\">U bent vergeten het verplichte veld ".dodosmail_error_handle($required_var_name)." in te vullen. Klik op terug om het formulier correct in te vullen en nogmaals te verzenden.\n";
echo "<br /><br /><a href=\"javascript:history.back(1)\">Terug</a>\n";
echo "</p>\n";
include_dodosmail_footer($dodosmail_footer_file);
exit;
}
}
if($check_email_address == "yes" && !empty($email)) {
if(!check_email($email)) {
include_dodosmail_header($dodosmail_header_file);
echo "<p class=\"DodosMailError\">Fout - het adres ".dodosmail_error_handle($email)." is niet geldig.\n";
echo "<br /><br /><a href=\"javascript:history.back(1)\">Terug</a>\n";
echo "</p>\n";
include_dodosmail_footer($dodosmail_footer_file);
exit;
}
}
for($i = 0; $i < count($fields); $i++) {
$actual_var = $fields[$i];
if(in_array($actual_var, $reserved_vars)) {
$inside_mail = $inside_mail;
} else {
if(is_array($$actual_var)) {
$inside_mail.= "$actual_var: ";
foreach($$actual_var as $actual_val) {
$inside_mail.= "$actual_val ";
}
$inside_mail.= "\n";
} else {
$actual_val = stripslashes($$actual_var);
$inside_mail.= "$actual_var: $actual_val\n";
}
}
}
// getting other information from the form
$cname = gethostbyaddr($_SERVER[REMOTE_ADDR]);
$inside_mail.=
"
-----------------------------------------------------------------------
SENDER INFO:
IP: $_SERVER[REMOTE_ADDR]
Computer Name: $cname
Browser Type: $_SERVER[HTTP_USER_AGENT]
Page Referer: $_SERVER[HTTP_REFERER]
-----------------------------------------------------------------------
";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-MSMail-Priority: Normal\r\n";
$headers .= "X-Mailer: DodosMail 2.0 http://regretless.com/scripts/\r\n";
$headers .= "Content-type: text/plain; charset=\"iso-8859-1\"\r\n";
//$headers .= "Date: ".date("R")."\r\n";
$headers .= "From: $name <$email>\r\n";
$success = mail($your_email_address, $subject, $inside_mail, $headers);
if($success) {
if($autoresponse == "yes") {
$response_subject = stripslashes($response_subject);
$response_mail = stripslashes($response_mail);
mail($email, $response_subject, $response_mail, "From: $owner_name <$your_email_address>");
}
if($after_url == "") {
// out put send info
include_dodosmail_header($dodosmail_header_file);
echo "<p>\n";
echo "Het formulier is verzonden!</p><ul>";
for($i = 0; $i < count($fields); $i++) {
$actual_var = $fields[$i];
if(in_array($actual_var, $reserved_vars))
echo "";
else {
if(is_array($$actual_var)) {
echo "<li>$actual_var: ";
foreach($$actual_var as $actual_val) {
echo "$actual_val ";
}
echo "</li>\n";
} else {
$actual_val = stripslashes($$actual_var);
echo "<li>$actual_var: $actual_val</li>\n";
}
}
}
echo "</ul>\n<p></p>";
include_dodosmail_footer($dodosmail_footer_file);
exit;
} else {
headfunction($after_url);
}
} else {
include_dodosmail_header($dodosmail_header_file);
echo "<p class=\"DodosMailError\">Fout - Het formulier is tijdelijk niet bruikbaar, gebruik ".dodosmail_error_handle($your_email_address)." om contact op te nemen.\n";
echo "<br /><br /><a href=\"javascript:history.back(1)\">Terug</a>\n";
echo "</p>\n";
include_dodosmail_footer($dodosmail_footer_file);
exit;
}
function check_email($email) {
if( (preg_match('/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/', $email)) ||
(preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/',$email)) ) {
return true;
}
return false;
}
?>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
als de wiede weerga eruit!!!!!!!!!!!!!!!!!!!!!!!!!
Dat is om heel ver terug te gaan in de prehistory, het wordt er niet veiliger op, wel als je het weghaalt en een correcte form-handler maakt
Gewijzigd op 01/01/1970 01:00:00 door Noppes
echo "Het formulier is verzonden!</p><ul>";
En maak daar je eigen pagina mee op. Heb je geen idee hoe, leer dan HTML en zoek op hoe je 'echo' gebruikt in PHP.
html en css lukt me allemaal prima... maar php is een beetje nieuw voor me.
misschien dat ik maar eens op zoek moet naar een wat 'actueler' scriptje....
jullie zijn wel snel trouwens
Is dit een slecht script? Kunnen jullie mij dan misschien op een goed script wijzen waar ik mee aan de gang kan? Dan weet ik namelijk zeker dat ik met een goede basis begin.
Thanks
misschien domme vraag, maar wat is bumpen?
Niet Bumpen: Domme vragen bestaan niet.:
Gewijzigd op 01/01/1970 01:00:00 door denise
boven je bericht zit een papiertje met een potloodje die knop kan je gebruiken om je bericht aan te vullen of aan te passen.