php formulier
Heb een contactformulier dat goed werkt, maar nu wil ik het uitbereiden met het veld jaar. Bij het verzenden van het formulier wordt de tekst van het veld jaar niet mee verzonden. Wat doe ik fout? Alvast bedankt voor de reacties
hier de code van het formulier:
<form name="form" method="post" action="http://contactzend.php">
<table width="400" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="200" valign="top" align="right">Your Name: </td>
<td width="200" valign="top" align="left">
<input type="text" name="name" size="25" maxlength="200" />
</td>
</tr><tr>
<td width="200" valign="top" align="right">Your Email: </td>
<td width="200" valign="top" align="left">
<input type="text" name="email" size="25" maxlength="100" />
</td>
</tr><tr>
<td width="200" valign="top" align="right">jaar: </td>
<td width="200" valign="top" align="left">
<input type="text" name="jaar" size="25" maxlength="100" />
</td>
</tr><tr>
<td width="200" valign="top" align="right">Your Comments: </td>
<td width="200" valign="top" align="left">
<textarea name="msg" cols="25" rows="4"></textarea>
</td>
</tr><tr>
<td width="200" valign="top"> </td>
<td width="200" valign="top" align="left">
<input type="reset" name="Reset" value="Reset" />
<input type="submit" name="Submit" value="Submit" />
</td>
</tr>
</table>
</form>
Hier de code die de mail verzendt:
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
// VALUES FROM THE FORM
$name = $_POST['name'];
$jaar = $_post['jaar'];
$email = $_POST['email'];
$message = $_POST['msg'];
// ERROR & SECURITY CHECKS
if ( ( !$email ) ||
( strlen($_POST['email']) > 200 ) ||
( !preg_match("#^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$#", $email) )
)
{
print "Error: Invalid E-Mail Address";
exit;
}
if ( ( !$name ) ||
( strlen($name) > 100 ) ||
( preg_match("/[:=@\<\>]/", $name) )
)
{
print "Error: Invalid Name";
exit;
}
if ( preg_match("#cc:#i", $message, $matches) )
{
print "Error: Found Invalid Header Field";
exit;
}
if ( !$message )
{
print "Error: No Message";
exit;
}
if (eregi("\r",$email) || eregi("\n",$email)){
print "Error: Invalid E-Mail Address";
exit;
}
if (FALSE) {
print "Error: You cannot send to an email address on the same domain.";
exit;
}
// CREATE THE EMAIL
$headers = "Content-Type: text/plain; charset=iso-8859-1\n";
$headers .= "From: $name <$email>\n";
$headers .= "From: $jaar <$email>\n";
$recipient = "[email protected]";
$subject = "Aanmelding";
$message = wordwrap($message, 1024);
// SEND THE EMAIL TO YOU
mail($recipient, $subject, $message, $headers);
// REDIRECT TO THE THANKS PAGE
header("location: http://www.knmi.nl");
?>
// VALUES FROM THE FORM
$name = $_POST['name'];
$jaar = $_post['jaar'];
$email = $_POST['email'];
$message = $_POST['msg'];
// ERROR & SECURITY CHECKS
if ( ( !$email ) ||
( strlen($_POST['email']) > 200 ) ||
( !preg_match("#^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$#", $email) )
)
{
print "Error: Invalid E-Mail Address";
exit;
}
if ( ( !$name ) ||
( strlen($name) > 100 ) ||
( preg_match("/[:=@\<\>]/", $name) )
)
{
print "Error: Invalid Name";
exit;
}
if ( preg_match("#cc:#i", $message, $matches) )
{
print "Error: Found Invalid Header Field";
exit;
}
if ( !$message )
{
print "Error: No Message";
exit;
}
if (eregi("\r",$email) || eregi("\n",$email)){
print "Error: Invalid E-Mail Address";
exit;
}
if (FALSE) {
print "Error: You cannot send to an email address on the same domain.";
exit;
}
// CREATE THE EMAIL
$headers = "Content-Type: text/plain; charset=iso-8859-1\n";
$headers .= "From: $name <$email>\n";
$headers .= "From: $jaar <$email>\n";
$recipient = "[email protected]";
$subject = "Aanmelding";
$message = wordwrap($message, 1024);
// SEND THE EMAIL TO YOU
mail($recipient, $subject, $message, $headers);
// REDIRECT TO THE THANKS PAGE
header("location: http://www.knmi.nl");
?>
$jaar = $_post['jaar'];
POST is niet post.
Bedankt voor je snelle reactie! nu werkt het wel, maar wil eigenlijk het jaar in het bericht venster hebben, sorry ik ben een noob.
gr,
Dus:
Code (php)
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
<?
// CREATE THE EMAIL
$headers = "Content-Type: text/plain; charset=iso-8859-1\n";
$headers .= "From: $name <$email>\n";
$recipient = "[email protected]";
$subject = "Aanmelding";
$message = wordwrap($message, 1024);
$message .= "From: $jaar <$email>\n";
?>
// CREATE THE EMAIL
$headers = "Content-Type: text/plain; charset=iso-8859-1\n";
$headers .= "From: $name <$email>\n";
$recipient = "[email protected]";
$subject = "Aanmelding";
$message = wordwrap($message, 1024);
$message .= "From: $jaar <$email>\n";
?>
Gewijzigd op 01/01/1970 01:00:00 door Wim E
Gewijzigd op 01/01/1970 01:00:00 door Wim E
alvast bedankt voor je reactie.
Heb het zelf op kunnen lossen, bedankt voor jullie hulp! gr