Inpute file form
Ik heb een werkende contact formulier. Nu wil ik er nog een file input veld bij (deze is al aangemaakt ) maar werkt niet.
Ik weet wel nieuwe velden aan te maken (ook werkend), alleen met type input is het voor mij wat lastiger.
Wat moet ik hierin plaatsen om afbeelingen met een contact form mee te sturen (de velden zijn al aangemaakt).
************************************************************
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
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
<?php
function Headline()
{
global $context, $mbname, $webmaster_email, $txt, $sourcedir, $modSettings, $scripturl;
// Check if the current user can send a message
isAllowedTo('view_headline');
if (isset($_GET['sa']))
{
if ($_GET['sa'] == 'save')
{
// Check whether the visual verification code was entered correctly.
if ((empty($modSettings['disable_visual_verification']) || $modSettings['disable_visual_verification'] != 1) && (empty($_REQUEST['visual_verification_code']) || strtoupper($_REQUEST['visual_verification_code']) !== $_SESSION['visual_verification_code']))
{
$_SESSION['visual_errors'] = isset($_SESSION['visual_errors']) ? $_SESSION['visual_errors'] + 1 : 1;
if ($_SESSION['visual_errors'] > 3 && isset($_SESSION['visual_verification_code']))
unset($_SESSION['visual_verification_code']);
fatal_lang_error('visual_verification_failed', false);
}
elseif (isset($_SESSION['visual_errors']))
unset($_SESSION['visual_errors']);
$from = $_POST['from'];
if ($from == '')
fatal_error($txt['smfcontact_errname'], false);
$subject = $_POST['subject'];
if ($subject == '')
fatal_error($txt['smfcontact_errsubject'], false);
$message = $_POST['message'];
if ($message == '')
fatal_error($txt['smfcontact_errmessage'], false);
$email = $_POST['email'];
if ($email == '')
fatal_error($txt['smfcontact_erremail'], false);
$phone = $_POST['phone'];
if ($phone == '')
fatal_error($txt['smfcontact_errphone'], false);
$titel = $_POST['titel'];
if ($titel == 'titel')
fatal_error($txt['smfcontact_errtitel'], false);
$artikelbron = $_POST['artikelbron'];
$foto = $_POST['foto'];
$fotobron = $_POST['fotobron'];
$subject = htmlspecialchars($subject, ENT_QUOTES);
$message = htmlspecialchars($message, ENT_QUOTES);
$from = htmlspecialchars($from, ENT_QUOTES);
$email = htmlspecialchars($email, ENT_QUOTES);
$titel = htmlspecialchars($titel, ENT_QUOTES);
$artikelbron = htmlspecialchars($artikelbron, ENT_QUOTES);
$foto = htmlspecialchars($foto, ENT_QUOTES);
$fotobron = htmlspecialchars($fotobron, ENT_QUOTES);
$m = $txt['smfcontact_form'] . $mbname . " \n";
$m .= "\n";
$m .= $txt['smfcontact_formname'] . $from . "\n";
$m .= $txt['smfcontact_formemail'] . $email . "\n";
$m .= $txt['smfcontact_formphone'] . $phone . "\n";
$m .= $txt['smfcontact_formtitel'] . $titel . "\n";
$m .= $txt['smfcontact_formartikelbron'] . $artikelbron . "\n";
$m .= $txt['smfcontact_formfoto'] . $foto . "\n";
$m .= $txt['smfcontact_formfotobron'] . $fotobron . "\n";
$m .= "\n";
$m .= $txt['smfcontact_formmessage'];
$m .= $message;
$m .= "\n";
// For send mail function
require_once($sourcedir . '/Subs-Post.php');
// Send email to webmaster
sendmail($webmaster_email, $subject, $m,$email);
// Show template that mail was sent
loadtemplate('Headline');
// Load the main contact template
$context['sub_template'] = 'send';
// Set the page title
$context['page_title'] = $mbname . $txt['smfcontact_titlesent'];
}
}
else
{
// Load the main Contact template
loadtemplate('Headline');
// Language strings
loadLanguage('Login');
// Load the main Contact template
$context['sub_template'] = 'main';
// Set the page title
$context['page_title'] = $mbname . ' - ' . $txt['smfcontact_contact'];
// Generate a visual verification code to make sure the user is no bot.
$context['visual_verification'] = empty($modSettings['disable_visual_verification']) || $modSettings['disable_visual_verification'] != 1;
if ($context['visual_verification'])
{
$context['use_graphic_library'] = in_array('gd', get_loaded_extensions());
$context['verificiation_image_href'] = $scripturl . '?action=verificationcode;rand=' . md5(rand());
// Only generate a new code if one hasn't been set yet
if (!isset($_SESSION['visual_verification_code']))
{
// Skip I, J, L, O and Q.
$character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P'), range('R', 'Z'));
// Generate a new code.
$_SESSION['visual_verification_code'] = '';
for ($i = 0; $i < 5; $i++)
$_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)];
}
}
}
}
?>
function Headline()
{
global $context, $mbname, $webmaster_email, $txt, $sourcedir, $modSettings, $scripturl;
// Check if the current user can send a message
isAllowedTo('view_headline');
if (isset($_GET['sa']))
{
if ($_GET['sa'] == 'save')
{
// Check whether the visual verification code was entered correctly.
if ((empty($modSettings['disable_visual_verification']) || $modSettings['disable_visual_verification'] != 1) && (empty($_REQUEST['visual_verification_code']) || strtoupper($_REQUEST['visual_verification_code']) !== $_SESSION['visual_verification_code']))
{
$_SESSION['visual_errors'] = isset($_SESSION['visual_errors']) ? $_SESSION['visual_errors'] + 1 : 1;
if ($_SESSION['visual_errors'] > 3 && isset($_SESSION['visual_verification_code']))
unset($_SESSION['visual_verification_code']);
fatal_lang_error('visual_verification_failed', false);
}
elseif (isset($_SESSION['visual_errors']))
unset($_SESSION['visual_errors']);
$from = $_POST['from'];
if ($from == '')
fatal_error($txt['smfcontact_errname'], false);
$subject = $_POST['subject'];
if ($subject == '')
fatal_error($txt['smfcontact_errsubject'], false);
$message = $_POST['message'];
if ($message == '')
fatal_error($txt['smfcontact_errmessage'], false);
$email = $_POST['email'];
if ($email == '')
fatal_error($txt['smfcontact_erremail'], false);
$phone = $_POST['phone'];
if ($phone == '')
fatal_error($txt['smfcontact_errphone'], false);
$titel = $_POST['titel'];
if ($titel == 'titel')
fatal_error($txt['smfcontact_errtitel'], false);
$artikelbron = $_POST['artikelbron'];
$foto = $_POST['foto'];
$fotobron = $_POST['fotobron'];
$subject = htmlspecialchars($subject, ENT_QUOTES);
$message = htmlspecialchars($message, ENT_QUOTES);
$from = htmlspecialchars($from, ENT_QUOTES);
$email = htmlspecialchars($email, ENT_QUOTES);
$titel = htmlspecialchars($titel, ENT_QUOTES);
$artikelbron = htmlspecialchars($artikelbron, ENT_QUOTES);
$foto = htmlspecialchars($foto, ENT_QUOTES);
$fotobron = htmlspecialchars($fotobron, ENT_QUOTES);
$m = $txt['smfcontact_form'] . $mbname . " \n";
$m .= "\n";
$m .= $txt['smfcontact_formname'] . $from . "\n";
$m .= $txt['smfcontact_formemail'] . $email . "\n";
$m .= $txt['smfcontact_formphone'] . $phone . "\n";
$m .= $txt['smfcontact_formtitel'] . $titel . "\n";
$m .= $txt['smfcontact_formartikelbron'] . $artikelbron . "\n";
$m .= $txt['smfcontact_formfoto'] . $foto . "\n";
$m .= $txt['smfcontact_formfotobron'] . $fotobron . "\n";
$m .= "\n";
$m .= $txt['smfcontact_formmessage'];
$m .= $message;
$m .= "\n";
// For send mail function
require_once($sourcedir . '/Subs-Post.php');
// Send email to webmaster
sendmail($webmaster_email, $subject, $m,$email);
// Show template that mail was sent
loadtemplate('Headline');
// Load the main contact template
$context['sub_template'] = 'send';
// Set the page title
$context['page_title'] = $mbname . $txt['smfcontact_titlesent'];
}
}
else
{
// Load the main Contact template
loadtemplate('Headline');
// Language strings
loadLanguage('Login');
// Load the main Contact template
$context['sub_template'] = 'main';
// Set the page title
$context['page_title'] = $mbname . ' - ' . $txt['smfcontact_contact'];
// Generate a visual verification code to make sure the user is no bot.
$context['visual_verification'] = empty($modSettings['disable_visual_verification']) || $modSettings['disable_visual_verification'] != 1;
if ($context['visual_verification'])
{
$context['use_graphic_library'] = in_array('gd', get_loaded_extensions());
$context['verificiation_image_href'] = $scripturl . '?action=verificationcode;rand=' . md5(rand());
// Only generate a new code if one hasn't been set yet
if (!isset($_SESSION['visual_verification_code']))
{
// Skip I, J, L, O and Q.
$character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P'), range('R', 'Z'));
// Generate a new code.
$_SESSION['visual_verification_code'] = '';
for ($i = 0; $i < 5; $i++)
$_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)];
}
}
}
}
?>
Ophalen met $_FILES['...'].
En in <form> enctype="..." zetten.
Gewijzigd op 01/01/1970 01:00:00 door - SanThe -