Ik krijg de volgende melding: undefined index: subject in public/sites/www.protree.nl/php/contact.ph
Kunnen jullie mij helpen. Alvast bedankt.
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
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
<?php
include('contact-config.php');
$contact_form_version=strtolower($contact_form_version);
if(empty($my_email_address) || empty($contact_form_version) || ($contact_form_version!='php' && $contact_form_version!='html')) {
die('Error: The contact form has not been setup correctly.');
} else {
if($contact_form_version=='php') {
$formLocation='../contact.php';
} else if($contact_form_version=='html') {
$formLocation='../contact.html';
}
}
if(!empty($_POST['ajax']) && $_POST['ajax']=='1') {
$ajax=true;
} else {
$ajax=false;
}
if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['message'])) {
if($ajax || $contact_form_version=='html') {
die('U heeft niet alles/goed ingevuld.');
} else {
header("Location: $formLocation?msg=missing-variables");
exit;
}
}
if (!preg_match("/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,8})$/", $_POST['email'])) {
if($ajax || $contact_form_version=='html') {
die('Error: Invalid email address');
} else {
header("Location: $formLocation?msg=invalid-email-address");
exit;
}
}
$name=$_POST['name'];
$email=$_POST['email'];
$subject=$_POST['subject'];
$message=$_POST['message'];
$to=$my_email_address;
$headers = 'From: '.$name.' <'.$email.'>'." \r\n";
$headers .= 'Reply-To: '.$email."\r\n";
if(isset($cc) && $cc!='') {
$headers .= 'Cc: '.$cc."\r\n";
}
if(isset($bcc) && $bcc!='') {
$headers .= 'Bcc: '.$bcc."\r\n";
}
$headers .= 'X-Mailer: PHP/' . phpversion();
$subject = $subject;
$message = wordwrap($message, 70);
if(mail($to, $subject, $message, $headers)) {
if($ajax || $contact_form_version=='html') {
die('De email is verstuurd');
} else {
header("Location: $formLocation?msg=mail-sent");
exit;
}
} else {
if($ajax || $contact_form_version=='html') {
die('Error: Mail failed');
} else {
header("Location: $formLocation?msg=mail-failed");
exit;
}
}
?>
include('contact-config.php');
$contact_form_version=strtolower($contact_form_version);
if(empty($my_email_address) || empty($contact_form_version) || ($contact_form_version!='php' && $contact_form_version!='html')) {
die('Error: The contact form has not been setup correctly.');
} else {
if($contact_form_version=='php') {
$formLocation='../contact.php';
} else if($contact_form_version=='html') {
$formLocation='../contact.html';
}
}
if(!empty($_POST['ajax']) && $_POST['ajax']=='1') {
$ajax=true;
} else {
$ajax=false;
}
if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['message'])) {
if($ajax || $contact_form_version=='html') {
die('U heeft niet alles/goed ingevuld.');
} else {
header("Location: $formLocation?msg=missing-variables");
exit;
}
}
if (!preg_match("/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,8})$/", $_POST['email'])) {
if($ajax || $contact_form_version=='html') {
die('Error: Invalid email address');
} else {
header("Location: $formLocation?msg=invalid-email-address");
exit;
}
}
$name=$_POST['name'];
$email=$_POST['email'];
$subject=$_POST['subject'];
$message=$_POST['message'];
$to=$my_email_address;
$headers = 'From: '.$name.' <'.$email.'>'." \r\n";
$headers .= 'Reply-To: '.$email."\r\n";
if(isset($cc) && $cc!='') {
$headers .= 'Cc: '.$cc."\r\n";
}
if(isset($bcc) && $bcc!='') {
$headers .= 'Bcc: '.$bcc."\r\n";
}
$headers .= 'X-Mailer: PHP/' . phpversion();
$subject = $subject;
$message = wordwrap($message, 70);
if(mail($to, $subject, $message, $headers)) {
if($ajax || $contact_form_version=='html') {
die('De email is verstuurd');
} else {
header("Location: $formLocation?msg=mail-sent");
exit;
}
} else {
if($ajax || $contact_form_version=='html') {
die('Error: Mail failed');
} else {
header("Location: $formLocation?msg=mail-failed");
exit;
}
}
?>
De melding komt voort doordat je geen formulier-veldnaam met de name 'subject' hebt.
Regel 48 is een beetje zinloos: $subject = $subject;
Zal voortaan ook in mijn bericht de foutmelding vermelden.