mailform met bijlage
http://www.portretkunst.be/ZZ.php
Hoe kan dit gemixet worden met een ander formulier, met invulvelden, zoals dit:
Ik ben op zoek naar een mailform warbij de bezoeker zelf kan bepalen hoeveel bijlages die wil verzenden. Voorbeeld van onderstaande code zie je hier in actie: 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
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title> Upload Images </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
var maxImages = 5;
/* **** Do not edit below this line **** */
/* Dynamic Image File Upload Form */
/* Copyright 2010, Michael J. Hill. Used with permission. www.javascript-demos.com */
/* Free use of the code, so long as both copyright notices are kept intact */
var root = "";
var nInput = "";
var IE = navigator.appName == "Microsoft Internet Explorer" ? true : false;
function insertInput(){
if (nInput.length > Number(maxImages)+Number(2))
{
alert('Maximum '+maxImages + ' images');
return false;
}
var nextUpload = document.createElement('input');
nextUpload.type = "file";
nextUpload.name = "userImg[]";
nextUpload.size = "25";
nextUpload.className = 'fInput';
nextUpload.onchange = function(){buildList()}
var lastUpload = root.getElementsByTagName('input');
lastUpload = lastUpload[lastUpload.length-3];
root.insertBefore(nextUpload,lastUpload);
}
function removeInput(){
if (nInput.length > 4)
{
root.removeChild(nInput[nInput.length-4]);
}
buildList();
}
function buildList(){
var nContainer = document.getElementById('nameList');
while (nContainer.lastChild)
{
nContainer.removeChild(nContainer.lastChild);
}
var listCollection = [];
for (i=0; i<nInput.length; i++)
{
if (nInput[i].type == "file")
{
var fullName = nInput[i].value;
var fileName = fullName.match(/[^\/\\]+$/);
var splitName = fullName.split(".");
var fileType = splitName[splitName.length-1];
if (!fileType){return false}
fileType = fileType.toLowerCase();
if (fileType == 'jpg' || fileType == 'jpeg' || fileType == 'gif')
{
listCollection[i] = fileName;
}
else {
alert('Invalid file type\nMust be jpg, jpeg or gif');
}
}
}
for (i=0; i<listCollection.length; i++)
{
var newItem = document.createElement('li');
newItem.appendChild(document.createTextNode(i+1+'- '+listCollection[i]));
nContainer.appendChild(newItem);
}
var nBox = document.getElementById('listBox');
if (nBox.scrollHeight > 0)
{
nBox.scrollTop = nBox.scrollHeight;
}
}
function validate(currForm){
var fileName = "";
var nForm = currForm.getElementsByTagName('input');
for (i=0; i<nForm.length; i++)
{
if (nForm[i].name = "userImg" && nForm[i].value == "")
{
alert('Complete all fields');
return false;
}
fileName = nForm[i].value.match(/[^\/\\]+$/);
fileName = fileName[0].split(".");
fileName[1] = fileName[1].toLowerCase();
if (/[^\w ]/.test(fileName[0]) || fileName.length > 2)
{
alert('A file name must not contain any special characters\nlike an apostrophe, period or hyphen');
return false;
}
if (fileName[1] != 'jpg' && fileName[1] != 'jpeg' && fileName[1] != 'gif')
{
alert('One or more of the selections\n is an invalid file type');
return false;
}
}
return true;
}
function init(){
root = document.getElementsByTagName('fieldset')[0];
nInput = root.getElementsByTagName('input');
var nForm = document.forms['img_upload'];
nForm.onsubmit = function()
{
return validate(this);
}
nForm['userImg[]'].onchange = function()
{
buildList();
}
nForm['next'].onclick = function()
{
insertInput();
}
nForm['remove'].onclick = function()
{
removeInput();
}
}
IE ? attachEvent('onload', init, false) : addEventListener('load', init, false);
</script>
<style type="text/css">
body
{
margin-top: 60px;
background-color: #eae3c6;
}
.headline
{
width: 170px;
margin-left: auto;
margin-right: auto;
margin-bottom: 5px;
}
form
{
margin-top: 0px;
padding: 0px;
}
fieldset
{
width: 279px;
margin-left: auto;
margin-right: auto;
padding: 0px;
background-color: #f0fff0;
border: 1px solid #87ceeb;
}
legend
{
font-family: helvetica;
font-size: 10pt;
font-weight: bold;
color: #00008b;
background-color: #87ceeb;
padding-left: 3px;
padding-right: 3px;
margin-bottom: 5px;
}
ul
{
margin-top: 2px;
}
.blank
{
display: none;
}
.list_container
{
display: block;
margin: auto;
border: 1px solid #87ceeb;
font-family: tahoma;
font-size: 10pt;
color: #00008b;
width: 273px;
height: 100px;
overflow: auto;
background-color: #ffffe0;
padding: 2px;
}
.review_msg
{
width: 123px;
margin-left: auto;
margin-right: auto;
}
.fInput
{
font-family: times;
font-size: 10pt;
margin-bottom: 3px;
margin-left: 16px;
}
.nextBtn
{
width: 75px;
font-family: veranda;
font-size: 9pt;
font-weight: bold;
margin-left: 21px;
margin-top: 5px;
margin-bottom: 8px;
background-color: #fff8dc;
border: solid 1px black;
letter-spacing: 1px;
}
.submitBtn
{
width: 75px;
font-family: veranda;
font-size: 9pt;
font-weight: bold;
margin-top: 5px;
margin-bottom: 8px;
background-color: #fff8dc;
border: solid 1px black;
letter-spacing: 1px;
}
.removeBtn
{
width: 75px;
font-family: veranda;
font-size: 9pt;
font-weight: bold;
margin-top: 5px;
margin-bottom: 8px;
background-color: #fff8dc;
border: solid 1px black;
letter-spacing: 1px;
}
.copyright_MJH
{
width: 92%;
margin-left: auto;
margin-right: auto;
margin-top: 35px;
background-color: transparent;
text-align: center;
font-family: veranda;
font-size: 8pt;
color: #d3d3d3;
}
.copyright_MJH a
{
color: #b0e0e6;
text-decoration: none;
}
</style>
</head>
<body>
<h3 class="headline"> Upload Your Images </h3>
<div id="listBox" class="list_container">
<div class="review_msg">Review Your Choices</div>
<ul id="nameList"><li class="blank"></li></ul>
</div>
<form name="img_upload" method="post" action="" enctype="multipart/form-data">
<fieldset>
<legend> Image Upload </legend>
<input type="file" name="userImg[]" size="25" class="fInput">
<input type="button" name="next" value="Next" class="nextBtn">
<input type="submit" name="submit" value="Submit" class="submitBtn">
<input type="button" name="remove" value="Remove" class="removeBtn">
</fieldset>
</form>
<!-- This copyright notice must be included in the document where the code is used -->
<div class="copyright_MJH">
Dynamic Image File Upload Form, Copyright © 2010 Michael J. Hill
<a href="http://www.javascript-demos.com">JavaScript Demos</a>
All rights reserved. Used with permission.
</div>
<!-- This copyright notice must be included in the document where the code is used -->
</body>
</html>
<html>
<head>
<title> Upload Images </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
var maxImages = 5;
/* **** Do not edit below this line **** */
/* Dynamic Image File Upload Form */
/* Copyright 2010, Michael J. Hill. Used with permission. www.javascript-demos.com */
/* Free use of the code, so long as both copyright notices are kept intact */
var root = "";
var nInput = "";
var IE = navigator.appName == "Microsoft Internet Explorer" ? true : false;
function insertInput(){
if (nInput.length > Number(maxImages)+Number(2))
{
alert('Maximum '+maxImages + ' images');
return false;
}
var nextUpload = document.createElement('input');
nextUpload.type = "file";
nextUpload.name = "userImg[]";
nextUpload.size = "25";
nextUpload.className = 'fInput';
nextUpload.onchange = function(){buildList()}
var lastUpload = root.getElementsByTagName('input');
lastUpload = lastUpload[lastUpload.length-3];
root.insertBefore(nextUpload,lastUpload);
}
function removeInput(){
if (nInput.length > 4)
{
root.removeChild(nInput[nInput.length-4]);
}
buildList();
}
function buildList(){
var nContainer = document.getElementById('nameList');
while (nContainer.lastChild)
{
nContainer.removeChild(nContainer.lastChild);
}
var listCollection = [];
for (i=0; i<nInput.length; i++)
{
if (nInput[i].type == "file")
{
var fullName = nInput[i].value;
var fileName = fullName.match(/[^\/\\]+$/);
var splitName = fullName.split(".");
var fileType = splitName[splitName.length-1];
if (!fileType){return false}
fileType = fileType.toLowerCase();
if (fileType == 'jpg' || fileType == 'jpeg' || fileType == 'gif')
{
listCollection[i] = fileName;
}
else {
alert('Invalid file type\nMust be jpg, jpeg or gif');
}
}
}
for (i=0; i<listCollection.length; i++)
{
var newItem = document.createElement('li');
newItem.appendChild(document.createTextNode(i+1+'- '+listCollection[i]));
nContainer.appendChild(newItem);
}
var nBox = document.getElementById('listBox');
if (nBox.scrollHeight > 0)
{
nBox.scrollTop = nBox.scrollHeight;
}
}
function validate(currForm){
var fileName = "";
var nForm = currForm.getElementsByTagName('input');
for (i=0; i<nForm.length; i++)
{
if (nForm[i].name = "userImg" && nForm[i].value == "")
{
alert('Complete all fields');
return false;
}
fileName = nForm[i].value.match(/[^\/\\]+$/);
fileName = fileName[0].split(".");
fileName[1] = fileName[1].toLowerCase();
if (/[^\w ]/.test(fileName[0]) || fileName.length > 2)
{
alert('A file name must not contain any special characters\nlike an apostrophe, period or hyphen');
return false;
}
if (fileName[1] != 'jpg' && fileName[1] != 'jpeg' && fileName[1] != 'gif')
{
alert('One or more of the selections\n is an invalid file type');
return false;
}
}
return true;
}
function init(){
root = document.getElementsByTagName('fieldset')[0];
nInput = root.getElementsByTagName('input');
var nForm = document.forms['img_upload'];
nForm.onsubmit = function()
{
return validate(this);
}
nForm['userImg[]'].onchange = function()
{
buildList();
}
nForm['next'].onclick = function()
{
insertInput();
}
nForm['remove'].onclick = function()
{
removeInput();
}
}
IE ? attachEvent('onload', init, false) : addEventListener('load', init, false);
</script>
<style type="text/css">
body
{
margin-top: 60px;
background-color: #eae3c6;
}
.headline
{
width: 170px;
margin-left: auto;
margin-right: auto;
margin-bottom: 5px;
}
form
{
margin-top: 0px;
padding: 0px;
}
fieldset
{
width: 279px;
margin-left: auto;
margin-right: auto;
padding: 0px;
background-color: #f0fff0;
border: 1px solid #87ceeb;
}
legend
{
font-family: helvetica;
font-size: 10pt;
font-weight: bold;
color: #00008b;
background-color: #87ceeb;
padding-left: 3px;
padding-right: 3px;
margin-bottom: 5px;
}
ul
{
margin-top: 2px;
}
.blank
{
display: none;
}
.list_container
{
display: block;
margin: auto;
border: 1px solid #87ceeb;
font-family: tahoma;
font-size: 10pt;
color: #00008b;
width: 273px;
height: 100px;
overflow: auto;
background-color: #ffffe0;
padding: 2px;
}
.review_msg
{
width: 123px;
margin-left: auto;
margin-right: auto;
}
.fInput
{
font-family: times;
font-size: 10pt;
margin-bottom: 3px;
margin-left: 16px;
}
.nextBtn
{
width: 75px;
font-family: veranda;
font-size: 9pt;
font-weight: bold;
margin-left: 21px;
margin-top: 5px;
margin-bottom: 8px;
background-color: #fff8dc;
border: solid 1px black;
letter-spacing: 1px;
}
.submitBtn
{
width: 75px;
font-family: veranda;
font-size: 9pt;
font-weight: bold;
margin-top: 5px;
margin-bottom: 8px;
background-color: #fff8dc;
border: solid 1px black;
letter-spacing: 1px;
}
.removeBtn
{
width: 75px;
font-family: veranda;
font-size: 9pt;
font-weight: bold;
margin-top: 5px;
margin-bottom: 8px;
background-color: #fff8dc;
border: solid 1px black;
letter-spacing: 1px;
}
.copyright_MJH
{
width: 92%;
margin-left: auto;
margin-right: auto;
margin-top: 35px;
background-color: transparent;
text-align: center;
font-family: veranda;
font-size: 8pt;
color: #d3d3d3;
}
.copyright_MJH a
{
color: #b0e0e6;
text-decoration: none;
}
</style>
</head>
<body>
<h3 class="headline"> Upload Your Images </h3>
<div id="listBox" class="list_container">
<div class="review_msg">Review Your Choices</div>
<ul id="nameList"><li class="blank"></li></ul>
</div>
<form name="img_upload" method="post" action="" enctype="multipart/form-data">
<fieldset>
<legend> Image Upload </legend>
<input type="file" name="userImg[]" size="25" class="fInput">
<input type="button" name="next" value="Next" class="nextBtn">
<input type="submit" name="submit" value="Submit" class="submitBtn">
<input type="button" name="remove" value="Remove" class="removeBtn">
</fieldset>
</form>
<!-- This copyright notice must be included in the document where the code is used -->
<div class="copyright_MJH">
Dynamic Image File Upload Form, Copyright © 2010 Michael J. Hill
<a href="http://www.javascript-demos.com">JavaScript Demos</a>
All rights reserved. Used with permission.
</div>
<!-- This copyright notice must be included in the document where the code is used -->
</body>
</html>
Hoe kan dit gemixet worden met een ander formulier, met invulvelden, zoals dit:
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
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
<?php
if ($_POST["action"] == "send"){
if ($_POST[naam] != " je naam" and $_POST[naam] != "" and $_POST[email] != " je e-mail adres" and $_POST[email] != "" and $_POST[bericht] != "") {
mail ("[email protected]", "bericht via AM",
"
Naam: ".$_POST['naam']."
E-mail: ".$_POST['email']."
Bericht: ".$_POST['bericht']."
",
"From: ".$_POST['naam']." <".$_POST['email'].">");
$subject = "bevestiging bericht";
$msg = "
Dit is een automatisch verzonden mail. Gelieve niet te antwoorden.
Beste $_POST[naam],
Bedankt voor je bericht.
Je bericht is doorgestuurd; je mag binnen twee werkdagen een antwoord verwachten.
Dit was je bericht:
$_POST[bericht]
";
mail($_POST[email], $subject, $msg);
echo '<br><img src="images/sent.gif" style="border:0px;height:12px;width:12px;padding-right:10px;">Dankjewel.<br><br>Je bericht is verzonden, <br>en je zal een bevestiging ontvangen.';
}
else{
echo '<br><img src="images/clear.gif" style="border:0px;height:12px;width:12px;padding-right:10px;">Gelieve alle velden in te vullen.<br><br>Je naam, email adres en bericht<br> zijn verplichte velden.<br><br><a href="about.php"><font color="#565656;">[graag opnieuw]</font></a>';
}
}
?>
if ($_POST["action"] == "send"){
if ($_POST[naam] != " je naam" and $_POST[naam] != "" and $_POST[email] != " je e-mail adres" and $_POST[email] != "" and $_POST[bericht] != "") {
mail ("[email protected]", "bericht via AM",
"
Naam: ".$_POST['naam']."
E-mail: ".$_POST['email']."
Bericht: ".$_POST['bericht']."
",
"From: ".$_POST['naam']." <".$_POST['email'].">");
$subject = "bevestiging bericht";
$msg = "
Dit is een automatisch verzonden mail. Gelieve niet te antwoorden.
Beste $_POST[naam],
Bedankt voor je bericht.
Je bericht is doorgestuurd; je mag binnen twee werkdagen een antwoord verwachten.
Dit was je bericht:
$_POST[bericht]
";
mail($_POST[email], $subject, $msg);
echo '<br><img src="images/sent.gif" style="border:0px;height:12px;width:12px;padding-right:10px;">Dankjewel.<br><br>Je bericht is verzonden, <br>en je zal een bevestiging ontvangen.';
}
else{
echo '<br><img src="images/clear.gif" style="border:0px;height:12px;width:12px;padding-right:10px;">Gelieve alle velden in te vullen.<br><br>Je naam, email adres en bericht<br> zijn verplichte velden.<br><br><a href="about.php"><font color="#565656;">[graag opnieuw]</font></a>';
}
}
?>
Gewijzigd op 01/01/1970 01:00:00 door Chechu
Er zijn nog geen reacties op dit bericht.