mail form -> aanvullen met attachment
Ik heb nu een mailform, maar ik zou er graag nog de mogelijkheid inbouwen om een bijlage mee te versturen. Het form is in .html, en bij submit wordt onderstaand script uitgevoerd:
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
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
<?php
// get posted data into local variables
$EmailFrom = "*";
$EmailTo = "*";
$Subject = "*";
$Naam = Trim(stripslashes($_POST['Naam']));
$Voornaam = Trim(stripslashes($_POST['Voornaam']));
$Adres = Trim(stripslashes($_POST['Adres']));
$Woonplaats = Trim(stripslashes($_POST['Woonplaats']));
$Postcode = Trim(stripslashes($_POST['Postcode']));
$Provincie = Trim(stripslashes($_POST['Provincie']));
$Land = Trim(stripslashes($_POST['Land']));
$Lengte = Trim(stripslashes($_POST['Lengte']));
$Gewicht = Trim(stripslashes($_POST['Gewicht']));
$Maat = Trim(stripslashes($_POST['Maat']));
$Leeftijd = Trim(stripslashes($_POST['Leeftijd']));
$Email = Trim(stripslashes($_POST['Email']));
$Telefoon = Trim(stripslashes($_POST['Telefoon']));
$Studies = Trim(stripslashes($_POST['Studies']));
$Opmerkingen = Trim(stripslashes($_POST['Opmerkingen']));
//Validatieblablabla
// prepare email body text
$Body = "";
$Body .= "\n";
$Body .= "Naam: ";
$Body .= $Naam;
$Body .= "\n";
$Body .= "Voornaam: ";
$Body .= $Voornaam;
$Body .= "\n";
$Body .= "Adres: ";
$Body .= $Adres;
$Body .= "\n";
$Body .= "Woonplaats: ";
$Body .= $Woonplaats;
$Body .= "\n";
$Body .= "Postcode: ";
$Body .= $Postcode;
$Body .= "\n";
$Body .= "Provincie: ";
$Body .= $Provincie;
$Body .= "\n";
$Body .= "Land: ";
$Body .= $Land;
$Body .= "\n";
$Body .= "Lengte: ";
$Body .= $Lengte;
$Body .= "\n";
$Body .= "Gewicht: ";
$Body .= $Gewicht;
$Body .= "\n";
$Body .= "Maat: ";
$Body .= $Maat;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Telefoon: ";
$Body .= $Telefoon;
$Body .= "\n";
$Body .= "Leeftijd: ";
$Body .= $Leeftijd;
$Body .= "\n";
$Body .= "Studies: ";
$Body .= $Studies;
$Body .= "\n";
$Body .= "Opmerkingen: ";
$Body .= $Opmerkingen;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
?>
// get posted data into local variables
$EmailFrom = "*";
$EmailTo = "*";
$Subject = "*";
$Naam = Trim(stripslashes($_POST['Naam']));
$Voornaam = Trim(stripslashes($_POST['Voornaam']));
$Adres = Trim(stripslashes($_POST['Adres']));
$Woonplaats = Trim(stripslashes($_POST['Woonplaats']));
$Postcode = Trim(stripslashes($_POST['Postcode']));
$Provincie = Trim(stripslashes($_POST['Provincie']));
$Land = Trim(stripslashes($_POST['Land']));
$Lengte = Trim(stripslashes($_POST['Lengte']));
$Gewicht = Trim(stripslashes($_POST['Gewicht']));
$Maat = Trim(stripslashes($_POST['Maat']));
$Leeftijd = Trim(stripslashes($_POST['Leeftijd']));
$Email = Trim(stripslashes($_POST['Email']));
$Telefoon = Trim(stripslashes($_POST['Telefoon']));
$Studies = Trim(stripslashes($_POST['Studies']));
$Opmerkingen = Trim(stripslashes($_POST['Opmerkingen']));
//Validatieblablabla
// prepare email body text
$Body = "";
$Body .= "\n";
$Body .= "Naam: ";
$Body .= $Naam;
$Body .= "\n";
$Body .= "Voornaam: ";
$Body .= $Voornaam;
$Body .= "\n";
$Body .= "Adres: ";
$Body .= $Adres;
$Body .= "\n";
$Body .= "Woonplaats: ";
$Body .= $Woonplaats;
$Body .= "\n";
$Body .= "Postcode: ";
$Body .= $Postcode;
$Body .= "\n";
$Body .= "Provincie: ";
$Body .= $Provincie;
$Body .= "\n";
$Body .= "Land: ";
$Body .= $Land;
$Body .= "\n";
$Body .= "Lengte: ";
$Body .= $Lengte;
$Body .= "\n";
$Body .= "Gewicht: ";
$Body .= $Gewicht;
$Body .= "\n";
$Body .= "Maat: ";
$Body .= $Maat;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Telefoon: ";
$Body .= $Telefoon;
$Body .= "\n";
$Body .= "Leeftijd: ";
$Body .= $Leeftijd;
$Body .= "\n";
$Body .= "Studies: ";
$Body .= $Studies;
$Body .= "\n";
$Body .= "Opmerkingen: ";
$Body .= $Opmerkingen;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
?>
kan iemand mij hierbij helpen? alvast vriendelijk bedankt!!!
Gebruik de PHPmailer class die is vele malen beter dan dit onbeveiligde mailscriptje. Ook zitten daar de functies die jij zoekt standaard in.