Verwijzing wordt niet zichtbaar
Pagina: « vorige 1 2 3 volgende »
Er staat niks achter dus geldt ie alleen voor $onderwerp = 'Bevestigingsmail';
Een if() hoort te openen en te sluiten.
Je mist accolades vanwege je if-statement
if ($_POST["submit"]){
$onderwerp = 'Bevestigingsmail';
$webmaster = 'mijn e-mail'
Rest van de code
}
Ja, dat moet..
Overigens is 'Bevestigingse-mail' leuker dan 'Bevestigingsmail'.
Een simpel "Bevestiging" of "Bevestiging inschrijving" lijkt me wat netter.
In het onderwerp: "Gefeliciteerd! U heeft uw eerste bevestigingse-mail ontvangen van X!" :-)
"Gefeliciteerd! We hebben uw inschrijving ontvangen!"
;-)
Hebben jullie een suggestie?
Ik zie nu helemaal niets meer in de browser komen.
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
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
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
if($_POST["submit"]) {
$onderwerp = 'Bevestigingsmail';
$webmaster = 'mijn email';
$e-mailadres = $_POST['email'];
$naam = $_POST['fullname'];
$telefoonnummer = $_POST['cellphone'];
$stad = $_POST['city'];
$opmerking = $_POST['comment'];
$body = <<<EOD
<br><hr><br>
E-mail: $email <br>
Naam: $fullname <br>
telefoonnummer: $cellphone <br>
Stad: $city <br>
Opmerking: $comment <br>
EOD;
$headers = "from: $email\r\n";
$headers .= "conntent-type: text/html\r\n";
$success =mail ($webmaster, $onderwerp, $body, $headers);
}
// Set email variables
$email_to = 'mijn email';
$email_subject = 'Verrassing aanvraag';
// Set required fields
$required_fields = array('fullname','email','cellphone','city');
// set error messages
$error_messages = array(
'fullname' => 'Vul je naam in.',
'email' => 'Vul je e-mailadres in.',
'cellphone' => 'Vul je telefoonnummer in.',
'city' => 'Kies een stad.',
);
// Set form status
$form_complete = FALSE;
// configure validation array
$validation = array();
// check form submittal
if(!empty($_POST)) {
// Sanitise POST array
foreach($_POST as $key => $value) $_POST[$key] = remove_email_injection(trim($value));
// Loop into required fields and make sure they match our needs
foreach($required_fields as $field) {
// the field has been submitted?
if(!array_key_exists($field, $_POST)) array_push($validation, $field);
// check there is information in the field?
if($_POST[$field] == '') array_push($validation, $field);
// validate the email address supplied
if($field == 'email') if(!validate_email_address($_POST[$field])) array_push($validation, $field);
}
// basic validation result
if(count($validation) == 0) {
// Prepare our content string
$email_content = 'New Website Comment: ' . "\n\n";
// simple email content
foreach($_POST as $key => $value) {
if($key != 'submit') $email_content .= $key . ': ' . $value . "\n";
}
// if validation passed ok then send the email
mail($email_to, $email_subject, $email_content);
// Update form switch
$form_complete = TRUE;
}
}
function validate_email_address($email = FALSE) {
return (preg_match('/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i', $email))? TRUE : FALSE;
}
function remove_email_injection($field = FALSE) {
return (str_ireplace(array("\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:"), '', $field));
}
?>
<!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" xml:lang="en" lang="en">
<head>
<title>Contact Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="contactform.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/mootools/1.3.0/mootools-yui-compressed.js"></script>
<script type="text/javascript" src="validation.js"></script>
<script type="text/javascript">
var nameError = '<?php echo $error_messages['fullname']; ?>';
var emailError = '<?php echo $error_messages['email']; ?>';
var cellphoneError = '<?php echo $error_messages['cellphone']; ?>';
var cityError = '<?php echo $error_messages['city']; ?>';
</script>
</head>
<body>
<div id="formWrap">
<div id="form">
</div>
<form action="contact.php" method="post" id="comments_form">
<?php if($form_complete === FALSE): ?>
<div class="row">
<div class="label"> Voor en achternaam </div>
<div class="input">
<input type="text" id="fullname" class="detail" name="fullname" value="<?php echo isset($_POST['fullname'])? $_POST['fullname'] : ''; ?>" /><?php if(in_array('fullname', $validation)): ?><span class="error"><?php echo $error_messages['fullname']; ?></span><?php endif; ?>
<div class="context"></div>
</div>
</div>
<div class="row">
<div class="label"> E-mailadres </div>
<div class="input">
<input type="text" id="e-mail" class="detail" name="email" value="<?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>" /><?php if(in_array('email', $validation)): ?><span class="error"><?php echo $error_messages['email']; ?></span><?php endif; ?>
<div class="context"></div>
</div>
</div>
<div class="row">
<div class="label"> Telefoonnummer </div>
<div class="input">
<input type="number" id="cellphone" class="detail" name="cellphone" value="<?php echo isset($_POST['cellphone'])? $_POST['cellphone'] : ''; ?>" /><?php if(in_array('cellphone', $validation)): ?><span class="error"><?php echo $error_messages['cellphone']; ?></span><?php endif; ?>
<div class="context"></div>
</div>
</div>
<div class="row">
<div class="label"> In welke stad? </div>
<div class="input">
<select>
<option value="Utrecht">Utrecht</option>
</select>
<input type="dropdown" id="city" class="" name="city" value="<?php echo isset($_POST['city'])? $_POST['city'] : ''; ?>" /><?php if(in_array('city', $validation)): ?><span class="error"><?php echo $error_messages['city']; ?></span><?php endif; ?>
</div>
</div>
<div class="row">
<div class="label"> Opmerkingen </div>
<div class="input">
<textarea id= "comment" name="comment" class="mess"><?php echo isset($_POST['comment'])? $_POST['comment'] : ''; ?></textarea><?php if(in_array('comment', $validation)): ?><span class="error"><?php echo $error_messages['comment']; ?></span><?php endif; ?>
</div>
</div>
<div class="submit">
<input type= "submit" id="submit" name="submit" value="send message" />
</div>
</form>
<?php else: ?>
<p>Thank you for your Message!</p>
<script type="text-javascript">
window.setTimeout("location=('index.html');",5000)
</script>
<?php endif; ?>
</div>
</body>
</html>
ini_set('display_errors', 1);
error_reporting(E_ALL);
if($_POST["submit"]) {
$onderwerp = 'Bevestigingsmail';
$webmaster = 'mijn email';
$e-mailadres = $_POST['email'];
$naam = $_POST['fullname'];
$telefoonnummer = $_POST['cellphone'];
$stad = $_POST['city'];
$opmerking = $_POST['comment'];
$body = <<<EOD
<br><hr><br>
E-mail: $email <br>
Naam: $fullname <br>
telefoonnummer: $cellphone <br>
Stad: $city <br>
Opmerking: $comment <br>
EOD;
$headers = "from: $email\r\n";
$headers .= "conntent-type: text/html\r\n";
$success =mail ($webmaster, $onderwerp, $body, $headers);
}
// Set email variables
$email_to = 'mijn email';
$email_subject = 'Verrassing aanvraag';
// Set required fields
$required_fields = array('fullname','email','cellphone','city');
// set error messages
$error_messages = array(
'fullname' => 'Vul je naam in.',
'email' => 'Vul je e-mailadres in.',
'cellphone' => 'Vul je telefoonnummer in.',
'city' => 'Kies een stad.',
);
// Set form status
$form_complete = FALSE;
// configure validation array
$validation = array();
// check form submittal
if(!empty($_POST)) {
// Sanitise POST array
foreach($_POST as $key => $value) $_POST[$key] = remove_email_injection(trim($value));
// Loop into required fields and make sure they match our needs
foreach($required_fields as $field) {
// the field has been submitted?
if(!array_key_exists($field, $_POST)) array_push($validation, $field);
// check there is information in the field?
if($_POST[$field] == '') array_push($validation, $field);
// validate the email address supplied
if($field == 'email') if(!validate_email_address($_POST[$field])) array_push($validation, $field);
}
// basic validation result
if(count($validation) == 0) {
// Prepare our content string
$email_content = 'New Website Comment: ' . "\n\n";
// simple email content
foreach($_POST as $key => $value) {
if($key != 'submit') $email_content .= $key . ': ' . $value . "\n";
}
// if validation passed ok then send the email
mail($email_to, $email_subject, $email_content);
// Update form switch
$form_complete = TRUE;
}
}
function validate_email_address($email = FALSE) {
return (preg_match('/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i', $email))? TRUE : FALSE;
}
function remove_email_injection($field = FALSE) {
return (str_ireplace(array("\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:"), '', $field));
}
?>
<!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" xml:lang="en" lang="en">
<head>
<title>Contact Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="contactform.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/mootools/1.3.0/mootools-yui-compressed.js"></script>
<script type="text/javascript" src="validation.js"></script>
<script type="text/javascript">
var nameError = '<?php echo $error_messages['fullname']; ?>';
var emailError = '<?php echo $error_messages['email']; ?>';
var cellphoneError = '<?php echo $error_messages['cellphone']; ?>';
var cityError = '<?php echo $error_messages['city']; ?>';
</script>
</head>
<body>
<div id="formWrap">
<div id="form">
</div>
<form action="contact.php" method="post" id="comments_form">
<?php if($form_complete === FALSE): ?>
<div class="row">
<div class="label"> Voor en achternaam </div>
<div class="input">
<input type="text" id="fullname" class="detail" name="fullname" value="<?php echo isset($_POST['fullname'])? $_POST['fullname'] : ''; ?>" /><?php if(in_array('fullname', $validation)): ?><span class="error"><?php echo $error_messages['fullname']; ?></span><?php endif; ?>
<div class="context"></div>
</div>
</div>
<div class="row">
<div class="label"> E-mailadres </div>
<div class="input">
<input type="text" id="e-mail" class="detail" name="email" value="<?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>" /><?php if(in_array('email', $validation)): ?><span class="error"><?php echo $error_messages['email']; ?></span><?php endif; ?>
<div class="context"></div>
</div>
</div>
<div class="row">
<div class="label"> Telefoonnummer </div>
<div class="input">
<input type="number" id="cellphone" class="detail" name="cellphone" value="<?php echo isset($_POST['cellphone'])? $_POST['cellphone'] : ''; ?>" /><?php if(in_array('cellphone', $validation)): ?><span class="error"><?php echo $error_messages['cellphone']; ?></span><?php endif; ?>
<div class="context"></div>
</div>
</div>
<div class="row">
<div class="label"> In welke stad? </div>
<div class="input">
<select>
<option value="Utrecht">Utrecht</option>
</select>
<input type="dropdown" id="city" class="" name="city" value="<?php echo isset($_POST['city'])? $_POST['city'] : ''; ?>" /><?php if(in_array('city', $validation)): ?><span class="error"><?php echo $error_messages['city']; ?></span><?php endif; ?>
</div>
</div>
<div class="row">
<div class="label"> Opmerkingen </div>
<div class="input">
<textarea id= "comment" name="comment" class="mess"><?php echo isset($_POST['comment'])? $_POST['comment'] : ''; ?></textarea><?php if(in_array('comment', $validation)): ?><span class="error"><?php echo $error_messages['comment']; ?></span><?php endif; ?>
</div>
</div>
<div class="submit">
<input type= "submit" id="submit" name="submit" value="send message" />
</div>
</form>
<?php else: ?>
<p>Thank you for your Message!</p>
<script type="text-javascript">
window.setTimeout("location=('index.html');",5000)
</script>
<?php endif; ?>
</div>
</body>
</html>
Ik zie zo een aantal variabelen die uit de lucht komen vallen en nergens zijn gedeclareerd.
Geen melding nee. Verder werk hij zonder de bovenste code wel.
PHP Parse error: syntax error, unexpected '=' in /var/www/html/index.php on line 13
@-SanThe-
Das niet enige fout in dit script, als je goed kijkt, zie je dat er 2x mail() voorkomt en dat al zijn $_POST niet deugt.
- SanThe - op 06/09/2015 18:53:03:
PHP Parse error: syntax error, unexpected '=' in /var/www/html/index.php on line 13
Deze foutmelding verschijnt niet op het scherm, maar komt uit de log-file van Apache.
Als deze fout opgelost is dan verschijnen de andere meldingen weer gewoon op het scherm.
De fout is '-'.
@-SanThe-
Ik zie hem anders wel verschijnen hoor.
Maar er zit inderdaad ook een fout in Line 13: @-SanThe-
Ik zie hem anders wel verschijnen hoor.
Gewijzigd op 06/09/2015 19:21:22 door DavY -
Ik begrijp dat het beter is om eerst wat dieper op het leren van de codes in te gaan ipv kopiëren van andere sites. Het is alleen zo dat ik dit maar één keer wil doen. Daarnaast is het gek dat het eerst goed werkt en met die code zie ik niets meer.
Dat geeft dus die bovenstaande error die alleen in de log-file te zien is.
Ik dacht: Laat TS er eerst maar eens naar kijken.
Maar jij geeft gelijk al het probleem aan.
Gewijzigd op 06/09/2015 19:25:43 door - SanThe -
Ik ga een aan de slag met de error die zichtbaar is.
Tnx
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
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
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
// Set required fields
$required_fields = array('fullname','email','cellphone','city', 'comment');
// set error messages
$error_messages = array(
'fullname' => 'Vul je naam in.',
'email' => 'Vul je e-mailadres in.',
'cellphone' => 'Vul je telefoonnummer in.',
'city' => 'Kies een stad.',
'comment' => 'Geef een opmerking op'
);
// Set form status
$form_complete = FALSE;
// configure validation array
$validation = array();
// check form submittal
if(!empty($_POST)) {
// Sanitise POST array
foreach($_POST as $key => $value) $_POST[$key] = remove_email_injection(trim($value));
// Loop into required fields and make sure they match our needs
foreach($required_fields as $field) {
// the field has been submitted?
if(!array_key_exists($field, $_POST)) array_push($validation, $field);
// check there is information in the field?
if($_POST[$field] == '') array_push($validation, $field);
// validate the email address supplied
if($field == 'email') if(!validate_email_address($_POST[$field])) array_push($validation, $field);
}
// basic validation result
if(count($validation) == 0) {
// Prepare our content string
$onderwerp = "Mijn onderwerp";
$emailadres = $_POST['email'];
$body = "";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= "From: [email protected]";
// simple email content
foreach($_POST as $key => $value) {
if($key != 'submit') $body .= $key . ': ' . $value . "\n";
}
// if validation passed ok then send the email
mail($emailadres, $onderwerp, $body, $headers);
// Update form switch
$form_complete = TRUE;
}
}
function validate_email_address($email = FALSE) {
return (preg_match('/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i', $email))? TRUE : FALSE;
}
function remove_email_injection($field = FALSE) {
return (str_ireplace(array("\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:"), '', $field));
}
?>
<!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" xml:lang="en" lang="en">
<head>
<title>Contact Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="contactform.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/mootools/1.3.0/mootools-yui-compressed.js"></script>
<script type="text/javascript" src="validation.js"></script>
<script type="text/javascript">
var nameError = '<?php echo $error_messages['fullname']; ?>';
var emailError = '<?php echo $error_messages['email']; ?>';
var cellphoneError = '<?php echo $error_messages['cellphone']; ?>';
var cityError = '<?php echo $error_messages['city']; ?>';
</script>
</head>
<body>
<div id="formWrap">
<div id="form">
</div>
<form action="" method="post" id="comments_form">
<?php if($form_complete === FALSE): ?>
<div class="row">
<div class="label"> Voor en achternaam </div>
<div class="input">
<input type="text" id="fullname" class="detail" name="fullname" value="<?php echo isset($_POST['fullname'])? $_POST['fullname'] : ''; ?>" /><?php if(in_array('fullname', $validation)): ?><span class="error"><?php echo $error_messages['fullname']; ?></span><?php endif; ?>
<div class="context"></div>
</div>
</div>
<div class="row">
<div class="label"> E-mailadres </div>
<div class="input">
<input type="text" id="e-mail" class="detail" name="email" value="<?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>" /><?php if(in_array('email', $validation)): ?><span class="error"><?php echo $error_messages['email']; ?></span><?php endif; ?>
<div class="context"></div>
</div>
</div>
<div class="row">
<div class="label"> Telefoonnummer </div>
<div class="input">
<input type="number" id="cellphone" class="detail" name="cellphone" value="<?php echo isset($_POST['cellphone'])? $_POST['cellphone'] : ''; ?>" /><?php if(in_array('cellphone', $validation)): ?><span class="error"><?php echo $error_messages['cellphone']; ?></span><?php endif; ?>
<div class="context"></div>
</div>
</div>
<div class="row">
<div class="label"> In welke stad? </div>
<div class="input">
<input type="text" id="city" class="" name="city" value="<?php echo isset($_POST['city'])? $_POST['city'] : ''; ?>" /><?php if(in_array('city', $validation)): ?><span class="error"><?php echo $error_messages['city']; ?></span><?php endif; ?>
</div>
</div>
<div class="row">
<div class="label"> Opmerkingen </div>
<div class="input">
<textarea id= "comment" name="comment" class="mess"><?php echo isset($_POST['comment'])? $_POST['comment'] : ''; ?></textarea><?php if(in_array('comment', $validation)): ?><span class="error"><?php echo $error_messages['comment']; ?></span><?php endif; ?>
</div>
</div>
<div class="submit">
<input type= "submit" id="submit" name="submit" value="send message" />
</div>
</form>
<?php else: ?>
<p>Thank you for your Message!</p>
<script type="text-javascript">
window.setTimeout("location=('index.html');",5000)
</script>
<?php endif; ?>
</div>
</body>
</html>
ini_set('display_errors', 1);
error_reporting(E_ALL);
// Set required fields
$required_fields = array('fullname','email','cellphone','city', 'comment');
// set error messages
$error_messages = array(
'fullname' => 'Vul je naam in.',
'email' => 'Vul je e-mailadres in.',
'cellphone' => 'Vul je telefoonnummer in.',
'city' => 'Kies een stad.',
'comment' => 'Geef een opmerking op'
);
// Set form status
$form_complete = FALSE;
// configure validation array
$validation = array();
// check form submittal
if(!empty($_POST)) {
// Sanitise POST array
foreach($_POST as $key => $value) $_POST[$key] = remove_email_injection(trim($value));
// Loop into required fields and make sure they match our needs
foreach($required_fields as $field) {
// the field has been submitted?
if(!array_key_exists($field, $_POST)) array_push($validation, $field);
// check there is information in the field?
if($_POST[$field] == '') array_push($validation, $field);
// validate the email address supplied
if($field == 'email') if(!validate_email_address($_POST[$field])) array_push($validation, $field);
}
// basic validation result
if(count($validation) == 0) {
// Prepare our content string
$onderwerp = "Mijn onderwerp";
$emailadres = $_POST['email'];
$body = "";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= "From: [email protected]";
// simple email content
foreach($_POST as $key => $value) {
if($key != 'submit') $body .= $key . ': ' . $value . "\n";
}
// if validation passed ok then send the email
mail($emailadres, $onderwerp, $body, $headers);
// Update form switch
$form_complete = TRUE;
}
}
function validate_email_address($email = FALSE) {
return (preg_match('/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i', $email))? TRUE : FALSE;
}
function remove_email_injection($field = FALSE) {
return (str_ireplace(array("\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:"), '', $field));
}
?>
<!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" xml:lang="en" lang="en">
<head>
<title>Contact Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="contactform.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/mootools/1.3.0/mootools-yui-compressed.js"></script>
<script type="text/javascript" src="validation.js"></script>
<script type="text/javascript">
var nameError = '<?php echo $error_messages['fullname']; ?>';
var emailError = '<?php echo $error_messages['email']; ?>';
var cellphoneError = '<?php echo $error_messages['cellphone']; ?>';
var cityError = '<?php echo $error_messages['city']; ?>';
</script>
</head>
<body>
<div id="formWrap">
<div id="form">
</div>
<form action="" method="post" id="comments_form">
<?php if($form_complete === FALSE): ?>
<div class="row">
<div class="label"> Voor en achternaam </div>
<div class="input">
<input type="text" id="fullname" class="detail" name="fullname" value="<?php echo isset($_POST['fullname'])? $_POST['fullname'] : ''; ?>" /><?php if(in_array('fullname', $validation)): ?><span class="error"><?php echo $error_messages['fullname']; ?></span><?php endif; ?>
<div class="context"></div>
</div>
</div>
<div class="row">
<div class="label"> E-mailadres </div>
<div class="input">
<input type="text" id="e-mail" class="detail" name="email" value="<?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>" /><?php if(in_array('email', $validation)): ?><span class="error"><?php echo $error_messages['email']; ?></span><?php endif; ?>
<div class="context"></div>
</div>
</div>
<div class="row">
<div class="label"> Telefoonnummer </div>
<div class="input">
<input type="number" id="cellphone" class="detail" name="cellphone" value="<?php echo isset($_POST['cellphone'])? $_POST['cellphone'] : ''; ?>" /><?php if(in_array('cellphone', $validation)): ?><span class="error"><?php echo $error_messages['cellphone']; ?></span><?php endif; ?>
<div class="context"></div>
</div>
</div>
<div class="row">
<div class="label"> In welke stad? </div>
<div class="input">
<input type="text" id="city" class="" name="city" value="<?php echo isset($_POST['city'])? $_POST['city'] : ''; ?>" /><?php if(in_array('city', $validation)): ?><span class="error"><?php echo $error_messages['city']; ?></span><?php endif; ?>
</div>
</div>
<div class="row">
<div class="label"> Opmerkingen </div>
<div class="input">
<textarea id= "comment" name="comment" class="mess"><?php echo isset($_POST['comment'])? $_POST['comment'] : ''; ?></textarea><?php if(in_array('comment', $validation)): ?><span class="error"><?php echo $error_messages['comment']; ?></span><?php endif; ?>
</div>
</div>
<div class="submit">
<input type= "submit" id="submit" name="submit" value="send message" />
</div>
</form>
<?php else: ?>
<p>Thank you for your Message!</p>
<script type="text-javascript">
window.setTimeout("location=('index.html');",5000)
</script>
<?php endif; ?>
</div>
</body>
</html>
Ik heb alleen kleine foutjes omtrent mail() en $_POST gecorrigeerd. De rest is aan je om verder uit te zoeken of vraag een van de jongens hier om je verder te helpen Bernard.
Gewijzigd op 06/09/2015 21:51:15 door DavY -
Het werkt nu inderdaad alleen ontvang ik nu zelf geen mail wat degene heeft ingevuld.