Doorlinken na verzenden contactformulier
www.vanogfashion.com/thankyou.html
Wie o wie kan mij alsjeblieft helpen?
Hier een gedeelte van het php script:
$successPage = '<meta http-equiv="refresh" content="2; url-http//www.vanogfashion.com/thankyou.html</html>';
$successPage = str_replace('<!--FIELDVALUE:uwnaam-->', $FTGuwnaam, $successPage);
$successPage = str_replace('<!--FIELDVALUE:adres-->', $FTGadres, $successPage);
$successPage = str_replace('<!--FIELDVALUE:postcodewoonplaats-->', $FTGpostcodewoonplaats, $successPage);
$successPage = str_replace('<!--FIELDVALUE:telefoonnummer-->', $FTGtelefoonnummer, $successPage);
$successPage = str_replace('<!--FIELDVALUE:emailadres-->', $FTGemailadres, $successPage);
$successPage = str_replace('<!--FIELDVALUE:bericht-->', $FTGbericht, $successPage);
$successPage = str_replace('<!--FIELDVALUE:beveiliging-->', $FTGbeveiliging, $successPage);
$successPage = str_replace('<!--FIELDVALUE:verzenden-->', $FTGverzenden, $successPage);
echo $successPage;
Ik heb een website gemaakt, en hij is bijna klaar. Ik ondervind echter nog een probleem met mijn contactformulier. Ik heb een contactformulier gemaakt, en het wordt verzonden en de content komt bij de goede adressen terecht. Echter nadat het is verzonden wil ik dat de bezoeker op een andere pagina terecht komt, en niet enkel wat witte tekst te zien krijgt, zoals dat nu het geval is. Ik heb al op vele forum's gezocht en flink gegoogeld en dingen uitgeprobeerd maar ik krijg het niet opgelost. Onderstaand is het .php script voor als het formulier succesvol is ingevuld. De onderstaande tekst komt er dan ook te staan als het formulier goed wordt ingevuld. Ik wil dus niet dat je tekst ziet, maar dat je door het php script wordt doorgestuurd naar Wie o wie kan mij alsjeblieft helpen?
Hier een gedeelte van het php script:
$successPage = '<meta http-equiv="refresh" content="2; url-http//www.vanogfashion.com/thankyou.html</html>';
$successPage = str_replace('<!--FIELDVALUE:uwnaam-->', $FTGuwnaam, $successPage);
$successPage = str_replace('<!--FIELDVALUE:adres-->', $FTGadres, $successPage);
$successPage = str_replace('<!--FIELDVALUE:postcodewoonplaats-->', $FTGpostcodewoonplaats, $successPage);
$successPage = str_replace('<!--FIELDVALUE:telefoonnummer-->', $FTGtelefoonnummer, $successPage);
$successPage = str_replace('<!--FIELDVALUE:emailadres-->', $FTGemailadres, $successPage);
$successPage = str_replace('<!--FIELDVALUE:bericht-->', $FTGbericht, $successPage);
$successPage = str_replace('<!--FIELDVALUE:beveiliging-->', $FTGbeveiliging, $successPage);
$successPage = str_replace('<!--FIELDVALUE:verzenden-->', $FTGverzenden, $successPage);
echo $successPage;
header().
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
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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
<?PHP
define('kOptional', true);
define('kMandatory', false);
define('kStringRangeFrom', 1);
define('kStringRangeTo', 2);
define('kStringRangeBetween', 3);
define('kYes', 'yes');
define('kNo', 'no');
error_reporting(E_ERROR | E_WARNING | E_PARSE);
ini_set('track_errors', true);
function CaptchaGenerator() {
if ( (!function_exists('imagejpeg')) && (!function_exists('imagepng')) ) {
exit;
}
$im = imagecreate(100,40);
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
$gray = imagecolorallocate($im, 150, 150, 150);
imagerectangle($im, 0, 0, 25, 39, $gray);
imagerectangle($im, 25, 0, 50, 39, $gray);
imagerectangle($im, 50, 0, 75, 39, $gray);
imagerectangle($im, 75, 0, 99, 39, $gray);
imageline($im, 0, 0, 25, 39, $gray);
imageline($im, 25, 0, 50, 39, $gray);
imageline($im, 50, 0, 75, 39, $gray);
imageline($im, 75, 0, 99, 39, $gray);
imageline($im, 0, 39, 25, 0, $gray);
imageline($im, 25, 39, 50, 0, $gray);
imageline($im, 50, 39, 75, 0, $gray);
imageline($im, 75, 39, 99, 0, $gray);
$c1 = rand(65, 90);
$c2 = rand(65, 90);
$c3 = rand(65, 90);
$c4 = rand(65, 90);
$c5 = rand(65, 90);
$textOut = chr($c1) . ' ' . chr($c2) . ' ' . chr($c3) . ' ' . chr($c4) . ' ' . chr($c5);
$textCaptcha = chr($c1) . chr($c2) . chr($c3) . chr($c4) . chr($c5);
$a = imagestring($im, 5, 11, 13, $textOut, $black);
$fileName = substr(md5($textCaptcha), 0, 12);
$captchaDir = realpath('../captchabestanden/');
if ( !is_dir( $captchaDir ) ) {
echo '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title>Error</title></head><body>Access Code Validatie Error: directory "../captchabestanden" niet gevonden. Script zal nu stoppen.</body></html>';
exit;
}
if ( !is_writable( $captchaDir ) ) {
echo '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title>Error</title></head><body>Access Code Validatie Error: directory "../captchabestanden" is niet beschrijfbaar. Script zal nu stoppen.</body></html>';
exit;
}
$handle = opendir( $captchaDir );
while ( $captchaFile = readdir($handle) ) {
if ( ( substr($captchaFile, 0, 1) != '.' ) && ( substr($captchaFile, 0, 1) != '_' ) && ( !is_dir( realpath('../captchabestanden/') . '/' . $captchaFile ) ) ) {
if ( ( filemtime( realpath('../captchabestanden/') . '/' . $captchaFile ) + 3600 ) < time() ) {
unlink( realpath('../captchabestanden/') . '/' . $captchaFile );
}
}
}
closedir( $handle );
$handle = @fopen( realpath('../captchabestanden/') . '/' . $fileName, 'w' );
if ( !$handle ) {
echo '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title>Error</title></head><body>Access Code Validatie Error: het is onmogelijk gebleken om een captcha controle bestand te maken. Script zal nu stoppen.</body></html>';
exit;
}
fclose($handle);
if (imagetypes() & IMG_JPG) {
header('Content-type: image/jpeg');
imagejpeg($im);
} elseif (imagetypes() & IMG_PNG) {
header('Content-type: image/png');
imagepng($im);
}
exit;
}
function DoStripSlashes($fieldValue) {
if ( function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() ) {
if (is_array($fieldValue) ) {
return array_map('DoStripSlashes', $fieldValue);
} else {
return trim(stripslashes($fieldValue));
}
} else {
return $fieldValue;
}
}
function FilterCChars($theString) {
return preg_replace('/[\x00-\x1F]/', '', $theString);
}
function CheckString($value, $low, $high, $mode, $limitAlpha, $limitNumbers, $limitEmptySpaces, $limitExtraChars, $optional) {
if ($limitAlpha == kYes) {
$regExp = 'A-Za-z';
}
if ($limitNumbers == kYes) {
$regExp .= '0-9';
}
if ($limitEmptySpaces == kYes) {
$regExp .= ' ';
}
if (strlen($limitExtraChars) > 0) {
$search = array('\\', '[', ']', '-', '$', '.', '*', '(', ')', '?', '+', '^', '{', '}', '|', '/');
$replace = array('\\\\', '\[', '\]', '\-', '\$', '\.', '\*', '\(', '\)', '\?', '\+', '\^', '\{', '\}', '\|', '\/');
$regExp .= str_replace($search, $replace, $limitExtraChars);
}
if ( (strlen($regExp) > 0) && (strlen($value) > 0) ){
if (preg_match('/[^' . $regExp . ']/', $value)) {
return false;
}
}
if ( (strlen($value) == 0) && ($optional === kOptional) ) {
return true;
} elseif ( (strlen($value) >= $low) && ($mode == kStringRangeFrom) ) {
return true;
} elseif ( (strlen($value) <= $high) && ($mode == kStringRangeTo) ) {
return true;
} elseif ( (strlen($value) >= $low) && (strlen($value) <= $high) && ($mode == kStringRangeBetween) ) {
return true;
} else {
return false;
}
}
function CheckEmail($email, $optional) {
if ( (strlen($email) == 0) && ($optional === kOptional) ) {
return true;
} elseif ( eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email) ) {
return true;
} else {
return false;
}
}
function CheckFTGCaptcha($accessCode) {
$captchaDir = realpath('../captchabestanden/');
if ( !is_dir( $captchaDir ) ) {
echo '<html><head><title>Error</title></head><body>Access Code Validatie Error: directory "../captchabestanden" niet gevonden. Script zal nu stoppen.</body></html>';
exit;
}
$handle = opendir( $captchaDir );
$fileAccessCode = substr( md5( $accessCode ), 0, 12 );
while ( $captchaFile = readdir( $handle ) ) {
if ( substr( $captchaFile, 0, 1 ) != '.' ) {
if ( $fileAccessCode == $captchaFile ) {
return true;
}
}
}
return false;
}
function DeleteCaptcha($accessCode) {
$captchaDir = realpath('../captchabestanden/');
if ( !is_dir( $captchaDir ) ) {
echo '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title>Error</title></head><body>Access Code Validatie Error: directory "../captchabestanden" niet gevonden. Script zal nu stoppen.</body></html>';
exit;
}
$handle = opendir( $captchaDir );
$fileAccessCode = substr( md5( $accessCode ), 0, 12 );
while ( $captchaFile = readdir( $handle ) ) {
if ( ( substr( $captchaFile, 0, 1 ) != '.' ) && ( substr( $captchaFile, 0, 1 ) != '_' ) && ( !is_dir( realpath('../captchabestanden/') . '/' . $captchaFile ) ) ) {
if ( $fileAccessCode == $captchaFile ) {
unlink( realpath('../captchabestanden/') . '/' . $captchaFile );
return;
}
}
}
}
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$clientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$clientIP = $_SERVER['REMOTE_ADDR'];
}
if ( isset($_REQUEST['captchaimage']) ) {
CaptchaGenerator();
exit;
}
$FTGuwnaam = DoStripSlashes( $_POST['uwnaam'] );
$FTGadres = DoStripSlashes( $_POST['adres'] );
$FTGpostcodewoonplaats = DoStripSlashes( $_POST['postcodewoonplaats'] );
$FTGtelefoonnummer = DoStripSlashes( $_POST['telefoonnummer'] );
$FTGemailadres = DoStripSlashes( $_POST['emailadres'] );
$FTGbericht = DoStripSlashes( $_POST['bericht'] );
$FTGbeveiliging = DoStripSlashes( $_POST['beveiliging'] );
$FTGverzenden = DoStripSlashes( $_POST['verzenden'] );
$validationFailed = false;
if (!CheckString($FTGuwnaam, 1, 0, kStringRangeFrom, kNo, kNo, kNo, '', kMandatory)) {
$FTGErrorMessage['uwnaam'] = '';
$validationFailed = true;
}
if (!CheckEmail($FTGemailadres, kMandatory)) {
$FTGErrorMessage['emailadres'] = '';
$validationFailed = true;
}
if (!CheckString($FTGbericht, 1, 0, kStringRangeFrom, kNo, kNo, kNo, '', kMandatory)) {
$FTGErrorMessage['bericht'] = '';
$validationFailed = true;
}
if (!CheckFTGCaptcha($FTGbeveiliging)) {
$FTGErrorMessage['beveiliging'] = '';
$validationFailed = true;
}
if ($validationFailed === true) {
$errorPage = '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title>Error</title></head><body>Het formulier is niet verstuurd. Probeer het nogmaals.</body></html>';
$errorPage = str_replace('<!--FIELDVALUE:uwnaam-->', $FTGuwnaam, $errorPage);
$errorPage = str_replace('<!--FIELDVALUE:adres-->', $FTGadres, $errorPage);
$errorPage = str_replace('<!--FIELDVALUE:postcodewoonplaats-->', $FTGpostcodewoonplaats, $errorPage);
$errorPage = str_replace('<!--FIELDVALUE:telefoonnummer-->', $FTGtelefoonnummer, $errorPage);
$errorPage = str_replace('<!--FIELDVALUE:emailadres-->', $FTGemailadres, $errorPage);
$errorPage = str_replace('<!--FIELDVALUE:bericht-->', $FTGbericht, $errorPage);
$errorPage = str_replace('<!--FIELDVALUE:beveiliging-->', $FTGbeveiliging, $errorPage);
$errorPage = str_replace('<!--FIELDVALUE:verzenden-->', $FTGverzenden, $errorPage);
$errorList = @implode("<br />\n", $FTGErrorMessage);
$errorPage = str_replace('<!--VALIDATIONERROR-->', $errorList, $errorPage);
echo $errorPage;
}
if ( $validationFailed === false ) {
$emailSubject = FilterCChars("Bericht via contactformulier vanogfashion.com");
$emailBody = "Uw naam : $FTGuwnaam\n"
. "Adres : $FTGadres\n"
. "Postcode + woonplaats : $FTGpostcodewoonplaats\n"
. "Telefoonnummer : $FTGtelefoonnummer\n"
. "E-mailadres : $FTGemailadres\n"
. "\n"
. "Bericht : $FTGbericht";
$emailTo = 'jouw naam <[email protected]>';
$emailFrom = FilterCChars("$FTGemailadres");
$emailHeader = "From: $emailFrom\n"
. "MIME-Version: 1.0\n"
. "Content-type: text/plain; charset=\"ISO-8859-1\"\n"
. "Content-transfer-encoding: 7bit\n";
mail($emailTo, $emailSubject, $emailBody, $emailHeader);
$confEmailTo = FilterCChars($FTGemailadres);
$confEmailSubject = FilterCChars("Kopie van uw verzonden bericht via www.vanogfashion.com");
$confEmailBody = "Uw naam : $FTGuwnaam\n"
. "Adres : $FTGadres\n"
. "Postcode + woonplaats : $FTGpostcodewoonplaats\n"
. "Telefoonnummer : $FTGtelefoonnummer\n"
. "E-mailadres : $FTGemailadres\n"
. "\n"
. "Bericht : $FTGbericht\n"
. "";
$confEmailHeader = "From: [email protected]\n"
. "MIME-Version: 1.0\n"
. "Content-type: text/plain; charset=\"ISO-8859-1\"\n"
. "Content-transfer-encoding: 7bit\n";
mail($confEmailTo, $confEmailSubject, $confEmailBody, $confEmailHeader);
DeleteCaptcha($FTGbeveiliging);
$successPage = '<?php header("Location: http://www.vanogfashion.com/thankyou"); /* Redirect browser */ ?> ';
$successPage = str_replace('<!--FIELDVALUE:uwnaam-->', $FTGuwnaam, $successPage);
$successPage = str_replace('<!--FIELDVALUE:adres-->', $FTGadres, $successPage);
$successPage = str_replace('<!--FIELDVALUE:postcodewoonplaats-->', $FTGpostcodewoonplaats, $successPage);
$successPage = str_replace('<!--FIELDVALUE:telefoonnummer-->', $FTGtelefoonnummer, $successPage);
$successPage = str_replace('<!--FIELDVALUE:emailadres-->', $FTGemailadres, $successPage);
$successPage = str_replace('<!--FIELDVALUE:bericht-->', $FTGbericht, $successPage);
$successPage = str_replace('<!--FIELDVALUE:beveiliging-->', $FTGbeveiliging, $successPage);
$successPage = str_replace('<!--FIELDVALUE:verzenden-->', $FTGverzenden, $successPage);
echo $successPage;
}
?>
define('kOptional', true);
define('kMandatory', false);
define('kStringRangeFrom', 1);
define('kStringRangeTo', 2);
define('kStringRangeBetween', 3);
define('kYes', 'yes');
define('kNo', 'no');
error_reporting(E_ERROR | E_WARNING | E_PARSE);
ini_set('track_errors', true);
function CaptchaGenerator() {
if ( (!function_exists('imagejpeg')) && (!function_exists('imagepng')) ) {
exit;
}
$im = imagecreate(100,40);
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
$gray = imagecolorallocate($im, 150, 150, 150);
imagerectangle($im, 0, 0, 25, 39, $gray);
imagerectangle($im, 25, 0, 50, 39, $gray);
imagerectangle($im, 50, 0, 75, 39, $gray);
imagerectangle($im, 75, 0, 99, 39, $gray);
imageline($im, 0, 0, 25, 39, $gray);
imageline($im, 25, 0, 50, 39, $gray);
imageline($im, 50, 0, 75, 39, $gray);
imageline($im, 75, 0, 99, 39, $gray);
imageline($im, 0, 39, 25, 0, $gray);
imageline($im, 25, 39, 50, 0, $gray);
imageline($im, 50, 39, 75, 0, $gray);
imageline($im, 75, 39, 99, 0, $gray);
$c1 = rand(65, 90);
$c2 = rand(65, 90);
$c3 = rand(65, 90);
$c4 = rand(65, 90);
$c5 = rand(65, 90);
$textOut = chr($c1) . ' ' . chr($c2) . ' ' . chr($c3) . ' ' . chr($c4) . ' ' . chr($c5);
$textCaptcha = chr($c1) . chr($c2) . chr($c3) . chr($c4) . chr($c5);
$a = imagestring($im, 5, 11, 13, $textOut, $black);
$fileName = substr(md5($textCaptcha), 0, 12);
$captchaDir = realpath('../captchabestanden/');
if ( !is_dir( $captchaDir ) ) {
echo '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title>Error</title></head><body>Access Code Validatie Error: directory "../captchabestanden" niet gevonden. Script zal nu stoppen.</body></html>';
exit;
}
if ( !is_writable( $captchaDir ) ) {
echo '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title>Error</title></head><body>Access Code Validatie Error: directory "../captchabestanden" is niet beschrijfbaar. Script zal nu stoppen.</body></html>';
exit;
}
$handle = opendir( $captchaDir );
while ( $captchaFile = readdir($handle) ) {
if ( ( substr($captchaFile, 0, 1) != '.' ) && ( substr($captchaFile, 0, 1) != '_' ) && ( !is_dir( realpath('../captchabestanden/') . '/' . $captchaFile ) ) ) {
if ( ( filemtime( realpath('../captchabestanden/') . '/' . $captchaFile ) + 3600 ) < time() ) {
unlink( realpath('../captchabestanden/') . '/' . $captchaFile );
}
}
}
closedir( $handle );
$handle = @fopen( realpath('../captchabestanden/') . '/' . $fileName, 'w' );
if ( !$handle ) {
echo '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title>Error</title></head><body>Access Code Validatie Error: het is onmogelijk gebleken om een captcha controle bestand te maken. Script zal nu stoppen.</body></html>';
exit;
}
fclose($handle);
if (imagetypes() & IMG_JPG) {
header('Content-type: image/jpeg');
imagejpeg($im);
} elseif (imagetypes() & IMG_PNG) {
header('Content-type: image/png');
imagepng($im);
}
exit;
}
function DoStripSlashes($fieldValue) {
if ( function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() ) {
if (is_array($fieldValue) ) {
return array_map('DoStripSlashes', $fieldValue);
} else {
return trim(stripslashes($fieldValue));
}
} else {
return $fieldValue;
}
}
function FilterCChars($theString) {
return preg_replace('/[\x00-\x1F]/', '', $theString);
}
function CheckString($value, $low, $high, $mode, $limitAlpha, $limitNumbers, $limitEmptySpaces, $limitExtraChars, $optional) {
if ($limitAlpha == kYes) {
$regExp = 'A-Za-z';
}
if ($limitNumbers == kYes) {
$regExp .= '0-9';
}
if ($limitEmptySpaces == kYes) {
$regExp .= ' ';
}
if (strlen($limitExtraChars) > 0) {
$search = array('\\', '[', ']', '-', '$', '.', '*', '(', ')', '?', '+', '^', '{', '}', '|', '/');
$replace = array('\\\\', '\[', '\]', '\-', '\$', '\.', '\*', '\(', '\)', '\?', '\+', '\^', '\{', '\}', '\|', '\/');
$regExp .= str_replace($search, $replace, $limitExtraChars);
}
if ( (strlen($regExp) > 0) && (strlen($value) > 0) ){
if (preg_match('/[^' . $regExp . ']/', $value)) {
return false;
}
}
if ( (strlen($value) == 0) && ($optional === kOptional) ) {
return true;
} elseif ( (strlen($value) >= $low) && ($mode == kStringRangeFrom) ) {
return true;
} elseif ( (strlen($value) <= $high) && ($mode == kStringRangeTo) ) {
return true;
} elseif ( (strlen($value) >= $low) && (strlen($value) <= $high) && ($mode == kStringRangeBetween) ) {
return true;
} else {
return false;
}
}
function CheckEmail($email, $optional) {
if ( (strlen($email) == 0) && ($optional === kOptional) ) {
return true;
} elseif ( eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email) ) {
return true;
} else {
return false;
}
}
function CheckFTGCaptcha($accessCode) {
$captchaDir = realpath('../captchabestanden/');
if ( !is_dir( $captchaDir ) ) {
echo '<html><head><title>Error</title></head><body>Access Code Validatie Error: directory "../captchabestanden" niet gevonden. Script zal nu stoppen.</body></html>';
exit;
}
$handle = opendir( $captchaDir );
$fileAccessCode = substr( md5( $accessCode ), 0, 12 );
while ( $captchaFile = readdir( $handle ) ) {
if ( substr( $captchaFile, 0, 1 ) != '.' ) {
if ( $fileAccessCode == $captchaFile ) {
return true;
}
}
}
return false;
}
function DeleteCaptcha($accessCode) {
$captchaDir = realpath('../captchabestanden/');
if ( !is_dir( $captchaDir ) ) {
echo '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title>Error</title></head><body>Access Code Validatie Error: directory "../captchabestanden" niet gevonden. Script zal nu stoppen.</body></html>';
exit;
}
$handle = opendir( $captchaDir );
$fileAccessCode = substr( md5( $accessCode ), 0, 12 );
while ( $captchaFile = readdir( $handle ) ) {
if ( ( substr( $captchaFile, 0, 1 ) != '.' ) && ( substr( $captchaFile, 0, 1 ) != '_' ) && ( !is_dir( realpath('../captchabestanden/') . '/' . $captchaFile ) ) ) {
if ( $fileAccessCode == $captchaFile ) {
unlink( realpath('../captchabestanden/') . '/' . $captchaFile );
return;
}
}
}
}
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$clientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$clientIP = $_SERVER['REMOTE_ADDR'];
}
if ( isset($_REQUEST['captchaimage']) ) {
CaptchaGenerator();
exit;
}
$FTGuwnaam = DoStripSlashes( $_POST['uwnaam'] );
$FTGadres = DoStripSlashes( $_POST['adres'] );
$FTGpostcodewoonplaats = DoStripSlashes( $_POST['postcodewoonplaats'] );
$FTGtelefoonnummer = DoStripSlashes( $_POST['telefoonnummer'] );
$FTGemailadres = DoStripSlashes( $_POST['emailadres'] );
$FTGbericht = DoStripSlashes( $_POST['bericht'] );
$FTGbeveiliging = DoStripSlashes( $_POST['beveiliging'] );
$FTGverzenden = DoStripSlashes( $_POST['verzenden'] );
$validationFailed = false;
if (!CheckString($FTGuwnaam, 1, 0, kStringRangeFrom, kNo, kNo, kNo, '', kMandatory)) {
$FTGErrorMessage['uwnaam'] = '';
$validationFailed = true;
}
if (!CheckEmail($FTGemailadres, kMandatory)) {
$FTGErrorMessage['emailadres'] = '';
$validationFailed = true;
}
if (!CheckString($FTGbericht, 1, 0, kStringRangeFrom, kNo, kNo, kNo, '', kMandatory)) {
$FTGErrorMessage['bericht'] = '';
$validationFailed = true;
}
if (!CheckFTGCaptcha($FTGbeveiliging)) {
$FTGErrorMessage['beveiliging'] = '';
$validationFailed = true;
}
if ($validationFailed === true) {
$errorPage = '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title>Error</title></head><body>Het formulier is niet verstuurd. Probeer het nogmaals.</body></html>';
$errorPage = str_replace('<!--FIELDVALUE:uwnaam-->', $FTGuwnaam, $errorPage);
$errorPage = str_replace('<!--FIELDVALUE:adres-->', $FTGadres, $errorPage);
$errorPage = str_replace('<!--FIELDVALUE:postcodewoonplaats-->', $FTGpostcodewoonplaats, $errorPage);
$errorPage = str_replace('<!--FIELDVALUE:telefoonnummer-->', $FTGtelefoonnummer, $errorPage);
$errorPage = str_replace('<!--FIELDVALUE:emailadres-->', $FTGemailadres, $errorPage);
$errorPage = str_replace('<!--FIELDVALUE:bericht-->', $FTGbericht, $errorPage);
$errorPage = str_replace('<!--FIELDVALUE:beveiliging-->', $FTGbeveiliging, $errorPage);
$errorPage = str_replace('<!--FIELDVALUE:verzenden-->', $FTGverzenden, $errorPage);
$errorList = @implode("<br />\n", $FTGErrorMessage);
$errorPage = str_replace('<!--VALIDATIONERROR-->', $errorList, $errorPage);
echo $errorPage;
}
if ( $validationFailed === false ) {
$emailSubject = FilterCChars("Bericht via contactformulier vanogfashion.com");
$emailBody = "Uw naam : $FTGuwnaam\n"
. "Adres : $FTGadres\n"
. "Postcode + woonplaats : $FTGpostcodewoonplaats\n"
. "Telefoonnummer : $FTGtelefoonnummer\n"
. "E-mailadres : $FTGemailadres\n"
. "\n"
. "Bericht : $FTGbericht";
$emailTo = 'jouw naam <[email protected]>';
$emailFrom = FilterCChars("$FTGemailadres");
$emailHeader = "From: $emailFrom\n"
. "MIME-Version: 1.0\n"
. "Content-type: text/plain; charset=\"ISO-8859-1\"\n"
. "Content-transfer-encoding: 7bit\n";
mail($emailTo, $emailSubject, $emailBody, $emailHeader);
$confEmailTo = FilterCChars($FTGemailadres);
$confEmailSubject = FilterCChars("Kopie van uw verzonden bericht via www.vanogfashion.com");
$confEmailBody = "Uw naam : $FTGuwnaam\n"
. "Adres : $FTGadres\n"
. "Postcode + woonplaats : $FTGpostcodewoonplaats\n"
. "Telefoonnummer : $FTGtelefoonnummer\n"
. "E-mailadres : $FTGemailadres\n"
. "\n"
. "Bericht : $FTGbericht\n"
. "";
$confEmailHeader = "From: [email protected]\n"
. "MIME-Version: 1.0\n"
. "Content-type: text/plain; charset=\"ISO-8859-1\"\n"
. "Content-transfer-encoding: 7bit\n";
mail($confEmailTo, $confEmailSubject, $confEmailBody, $confEmailHeader);
DeleteCaptcha($FTGbeveiliging);
$successPage = '<?php header("Location: http://www.vanogfashion.com/thankyou"); /* Redirect browser */ ?> ';
$successPage = str_replace('<!--FIELDVALUE:uwnaam-->', $FTGuwnaam, $successPage);
$successPage = str_replace('<!--FIELDVALUE:adres-->', $FTGadres, $successPage);
$successPage = str_replace('<!--FIELDVALUE:postcodewoonplaats-->', $FTGpostcodewoonplaats, $successPage);
$successPage = str_replace('<!--FIELDVALUE:telefoonnummer-->', $FTGtelefoonnummer, $successPage);
$successPage = str_replace('<!--FIELDVALUE:emailadres-->', $FTGemailadres, $successPage);
$successPage = str_replace('<!--FIELDVALUE:bericht-->', $FTGbericht, $successPage);
$successPage = str_replace('<!--FIELDVALUE:beveiliging-->', $FTGbeveiliging, $successPage);
$successPage = str_replace('<!--FIELDVALUE:verzenden-->', $FTGverzenden, $successPage);
echo $successPage;
}
?>
Code (php)
1
$successPage = '<?php header("Location: http://www.vanogfashion.com/thankyou"); /* Redirect browser */ ?> ';
Dit gaat niet werken..
Doe eens dit:
In plaats van
Gewijzigd op 29/07/2011 11:43:50 door Jack Sierkstra
De function eregi() is antiek. Gebruik preg_match().
Jack, ik weet niet hoe je dat hebt bedacht, maar bedankt! Nu werkt het! SanThe, ik heb het vervangen door preg_match, maar toen werkte het niet meer. Toen ik het terug heb veranderd werkte alles ineens. Kan het zijn dat ik nog meer moet veranderen of werkt mijn script gewoon niet met preg_match?
Preg_match() heeft net even iets andere syntax dan eregi(). Zie php.net voor info.