Captcha in email formulier plaatsenn
Sen schreef op 20.01.2010 23:52:
Beste mensen,
Ik wil captcha invoegen in me emailformulier. Contact pagina is me gelukt maar als je op verzenden klikt, krijg ik error. wat ik ook heb geprobeerd, het is me niet gelukt,
een beetje hulp stel ik zeer op prijs.
alvast bedankt
Voorbeeld staat op www.taxischipholservice.be
Hier zijn de paginas
Pagina 1
contact.php
Pagina 2
contact_email.php
En dit is het voorbeeld wat ik van internet heb gedownload
Ik wil captcha invoegen in me emailformulier. Contact pagina is me gelukt maar als je op verzenden klikt, krijg ik error. wat ik ook heb geprobeerd, het is me niet gelukt,
een beetje hulp stel ik zeer op prijs.
alvast bedankt
Voorbeeld staat op www.taxischipholservice.be
Hier zijn de paginas
Pagina 1
contact.php
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
<h1>Contact ons</h1><br />
<form method="post" action="contact_email.php">
<table>
<tr>
<td>Naam</td>
<td>:</td>
<td><input type="text" value="" name="naam">
</td>
</tr>
<tr>
<td>Telefoon</td><td>:</td>
<td>
<input type="text" value="" name="telefoon">
</td>
</tr>
<tr>
<td>E-mail</td><td>:</td>
<td>
<input type="text" value="" name="email">
</td>
</tr>
<tr>
<td>Onderwerp</td><td>:</td>
<td>
<input type="text" value="" name="onderwerp">
</td>
</tr><tr>
<td>Opmerkingen </td><td>:</td>
<td>
<textarea name="opmerkingen" Rows="5" Cols="49"></textarea>
</td>
</tr>
<tr>
<td>Word verification</td><td>:</td>
<td>
<div><img src="../../images/captcha/index.php?<?php echo session_name()?>=<?php echo session_id()?>" style="vertical-align:middle" /> <input type="text" name="keystring"></p>
</td>
</tr>
<tr>
<td> </td><td> </td>
<td><INPUT TYPE="checkbox" NAME="usermail" value="usermail"><small>E-mail een kopie van dit bericht naar uw eigen e-mailadres.</small>
</td>
</tr>
<tr>
<td> </td><td> </td>
<td><input type="submit" value=" Verzenden " name="submit">
<input type="reset" value=" Opnieuw "></td>
</tr>
</table>
</form>
<br />
<table>
<tr> <td>
</td></tr></table>
<div> </div>
</div>
<form method="post" action="contact_email.php">
<table>
<tr>
<td>Naam</td>
<td>:</td>
<td><input type="text" value="" name="naam">
</td>
</tr>
<tr>
<td>Telefoon</td><td>:</td>
<td>
<input type="text" value="" name="telefoon">
</td>
</tr>
<tr>
<td>E-mail</td><td>:</td>
<td>
<input type="text" value="" name="email">
</td>
</tr>
<tr>
<td>Onderwerp</td><td>:</td>
<td>
<input type="text" value="" name="onderwerp">
</td>
</tr><tr>
<td>Opmerkingen </td><td>:</td>
<td>
<textarea name="opmerkingen" Rows="5" Cols="49"></textarea>
</td>
</tr>
<tr>
<td>Word verification</td><td>:</td>
<td>
<div><img src="../../images/captcha/index.php?<?php echo session_name()?>=<?php echo session_id()?>" style="vertical-align:middle" /> <input type="text" name="keystring"></p>
</td>
</tr>
<tr>
<td> </td><td> </td>
<td><INPUT TYPE="checkbox" NAME="usermail" value="usermail"><small>E-mail een kopie van dit bericht naar uw eigen e-mailadres.</small>
</td>
</tr>
<tr>
<td> </td><td> </td>
<td><input type="submit" value=" Verzenden " name="submit">
<input type="reset" value=" Opnieuw "></td>
</tr>
</table>
</form>
<br />
<table>
<tr> <td>
</td></tr></table>
<div> </div>
</div>
Pagina 2
contact_email.php
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
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
<?php
// Data Form
$Onderwerp = $_POST['onderwerp'];
$Van = $_POST['email'];
$Ip .= $_SERVER['REMOTE_ADDR'];
$referer = $_SERVER['HTTP_REFERER'];
$logfile = date("d-m-Y, H:i:s", time());
if (isset($_POST["naam"])) $naam = $_POST["naam"];
if (isset($_POST["telefoon"])) $telefoon = $_POST["telefoon"];
if (isset($_POST["email"])) $email = $_POST["email"];
if (isset($_POST["onderwerp"])) $onderwerp = $_POST["onderwerp"];
if (isset($_POST["opmerkingen"])) $opmerkingen = $_POST["opmerkingen"];
$errors = array();
if (empty($naam)) $errors[] = "Naam";
if (empty($telefoon)) $errors[] = "Telefoon";
if(!preg_match ("/^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$/i", $_POST['email'])){ $errors[] = 'Correct e-mail'; }
if (empty($onderwerp)) $errors[] = "Onderwerp";
if (empty($opmerkingen)) $errors[] = "Opmerkingen";
if (empty($keystring)) $errors[] = "Word verification";
if ((count($errors)) != 0){
echo "<h1>Er is fout opgetreden, controleer de gegevens hieronder:</h1><br><font color='red'>";
for ($i=0; $i<count($errors); $i++){
echo $errors[$i]." invullen s.v.p.<br>";
}
echo "</font><br />";
echo "<a href='javascript:javascript:history.go(-1)'><font color='Blue'>Terug</font></a>";
} else {
if(isset($_POST['usermail'])) mail("$Van", "$Onderwerp", "Contact ons
Naam: $naam
Telefoon: $telefoon
E-mail: $email
Onderwerp: $onderwerp
Opmerkingen: $opmerkingen", "From: $Van");
require "../libs/db.php";
$sql = "INSERT INTO emailcontact VALUES (NULL, '$naam', '$telefoon', '$email', '$onderwerp', '$opmerkingen', '$logfile', '$Ip', '$referer')";
$res = mysql_query($sql);
// $res = 1;
if ($res){
require "../libs/config.php";
$ord = mysql_query("SELECT id FROM contactemail ORDER BY id DESC LIMIT 1");
$row = mysql_fetch_row($ord);
if (!empty($email)){
$receiver = $email;
}
$aan = "[email protected]";
$onderwerp = "$onderwerp";
$reservering = "
<h3>Contact ons </h3>
<table>
<tr><td>Naam</td><td>:</td><td>$naam</td></tr>
<tr><td>Telefoon</td><td>:</td><td>$telefoon</td></tr>
<tr><td>E-Mail</td><td>:</td><td>$email</td></tr>
<tr><td>Onderwerp</td><td>:</td><td>$onderwerp</td></tr>
<tr><td>Opmerkingen</td><td>:</td><td>$opmerkingen</td></tr>
</table>";
$headers = "From: ".$naam." <".$email.">\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "Reply-To: ".$naam." <".$email.">\r\n";
mail($aan, $onderwerp, $reservering, $headers);
?>
<h1>Contact ons </h1><br />
<strong>De volgende informatie is verzonden. We zullen zo spoedig mogelijk uw e-mail beantwoorden!</strong>
<br /><br />
<table>
<tr><td>Naam</td><td>:</td><td><?php echo $naam?></td></tr>
<tr><td>Telefoon</td><td>:</td><td><?php echo $telefoon?></td></tr>
<tr><td>E-mail</td><td>:</td><td><?php echo $email?></td></tr>
<tr><td>Onderwerp</td><td>:</td><td><?php echo $onderwerp?></td></tr>
<tr><td>Opmerkingen</td><td>:</td><td><?php echo $opmerkingen?></td></tr>
</table>
<?php
mysql_close($link);
} else {
echo "<h2>Er is fout opgetreden, probeer opnieuw</h2>";
}
}
?>
<br />
<div> </div>
</div>
<div class="clear"></div>
</div>
// Data Form
$Onderwerp = $_POST['onderwerp'];
$Van = $_POST['email'];
$Ip .= $_SERVER['REMOTE_ADDR'];
$referer = $_SERVER['HTTP_REFERER'];
$logfile = date("d-m-Y, H:i:s", time());
if (isset($_POST["naam"])) $naam = $_POST["naam"];
if (isset($_POST["telefoon"])) $telefoon = $_POST["telefoon"];
if (isset($_POST["email"])) $email = $_POST["email"];
if (isset($_POST["onderwerp"])) $onderwerp = $_POST["onderwerp"];
if (isset($_POST["opmerkingen"])) $opmerkingen = $_POST["opmerkingen"];
$errors = array();
if (empty($naam)) $errors[] = "Naam";
if (empty($telefoon)) $errors[] = "Telefoon";
if(!preg_match ("/^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$/i", $_POST['email'])){ $errors[] = 'Correct e-mail'; }
if (empty($onderwerp)) $errors[] = "Onderwerp";
if (empty($opmerkingen)) $errors[] = "Opmerkingen";
if (empty($keystring)) $errors[] = "Word verification";
if ((count($errors)) != 0){
echo "<h1>Er is fout opgetreden, controleer de gegevens hieronder:</h1><br><font color='red'>";
for ($i=0; $i<count($errors); $i++){
echo $errors[$i]." invullen s.v.p.<br>";
}
echo "</font><br />";
echo "<a href='javascript:javascript:history.go(-1)'><font color='Blue'>Terug</font></a>";
} else {
if(isset($_POST['usermail'])) mail("$Van", "$Onderwerp", "Contact ons
Naam: $naam
Telefoon: $telefoon
E-mail: $email
Onderwerp: $onderwerp
Opmerkingen: $opmerkingen", "From: $Van");
require "../libs/db.php";
$sql = "INSERT INTO emailcontact VALUES (NULL, '$naam', '$telefoon', '$email', '$onderwerp', '$opmerkingen', '$logfile', '$Ip', '$referer')";
$res = mysql_query($sql);
// $res = 1;
if ($res){
require "../libs/config.php";
$ord = mysql_query("SELECT id FROM contactemail ORDER BY id DESC LIMIT 1");
$row = mysql_fetch_row($ord);
if (!empty($email)){
$receiver = $email;
}
$aan = "[email protected]";
$onderwerp = "$onderwerp";
$reservering = "
<h3>Contact ons </h3>
<table>
<tr><td>Naam</td><td>:</td><td>$naam</td></tr>
<tr><td>Telefoon</td><td>:</td><td>$telefoon</td></tr>
<tr><td>E-Mail</td><td>:</td><td>$email</td></tr>
<tr><td>Onderwerp</td><td>:</td><td>$onderwerp</td></tr>
<tr><td>Opmerkingen</td><td>:</td><td>$opmerkingen</td></tr>
</table>";
$headers = "From: ".$naam." <".$email.">\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "Reply-To: ".$naam." <".$email.">\r\n";
mail($aan, $onderwerp, $reservering, $headers);
?>
<h1>Contact ons </h1><br />
<strong>De volgende informatie is verzonden. We zullen zo spoedig mogelijk uw e-mail beantwoorden!</strong>
<br /><br />
<table>
<tr><td>Naam</td><td>:</td><td><?php echo $naam?></td></tr>
<tr><td>Telefoon</td><td>:</td><td><?php echo $telefoon?></td></tr>
<tr><td>E-mail</td><td>:</td><td><?php echo $email?></td></tr>
<tr><td>Onderwerp</td><td>:</td><td><?php echo $onderwerp?></td></tr>
<tr><td>Opmerkingen</td><td>:</td><td><?php echo $opmerkingen?></td></tr>
</table>
<?php
mysql_close($link);
} else {
echo "<h2>Er is fout opgetreden, probeer opnieuw</h2>";
}
}
?>
<br />
<div> </div>
</div>
<div class="clear"></div>
</div>
En dit is het voorbeeld wat ik van internet heb gedownload
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
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
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<title>Sample Email Form: Thank You</title>
<?php
if (isset($_POST['submit'])) {
if (isset($_SESSION['captcha_keystring']) && $_SESSION['captcha_keystring'] == $_POST['keystring']) {
// Grab the form vars
$email = (isset($_POST['email'])) ? $_POST['email'] : '' ;
$message = (isset($_POST['message'])) ? $_POST['message'] : '' ;
$name = (isset($_POST['name'])) ? $_POST['name'] : '' ;
// Check for email injection
if (has_emailheaders($email)) {
die("Possible email injection occuring");
}
mail("[email protected]","Email Subject ",
"Name: $name\n
Email: $email\n\n
$message",
"From: $email");
$message = 'Your feedback has been received.';
} else {
$message = 'The word verification was not correct. Please press back and resubmit.';
}
} else {
$message = 'Please use the contact form for communication';
}
function has_emailheaders($text) {
return preg_match("/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i", $text);
}
?>
</head>
<body>
<div style="text-align:center">
<h1>Thank You for filling out our form</h1>
<h2><?php echo $message; ?></h2>
</div>
</body></html>
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<title>Sample Email Form: Thank You</title>
<?php
if (isset($_POST['submit'])) {
if (isset($_SESSION['captcha_keystring']) && $_SESSION['captcha_keystring'] == $_POST['keystring']) {
// Grab the form vars
$email = (isset($_POST['email'])) ? $_POST['email'] : '' ;
$message = (isset($_POST['message'])) ? $_POST['message'] : '' ;
$name = (isset($_POST['name'])) ? $_POST['name'] : '' ;
// Check for email injection
if (has_emailheaders($email)) {
die("Possible email injection occuring");
}
mail("[email protected]","Email Subject ",
"Name: $name\n
Email: $email\n\n
$message",
"From: $email");
$message = 'Your feedback has been received.';
} else {
$message = 'The word verification was not correct. Please press back and resubmit.';
}
} else {
$message = 'Please use the contact form for communication';
}
function has_emailheaders($text) {
return preg_match("/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i", $text);
}
?>
</head>
<body>
<div style="text-align:center">
<h1>Thank You for filling out our form</h1>
<h2><?php echo $message; ?></h2>
</div>
</body></html>
Gewijzigd op 01/01/1970 01:00:00 door Sen I
Ik zie niets dat je geprobeerd hebt?
Ik zie niets dat je geprobeerd hebt?
op contact_email.php had ik de codes ingevoegd maar ik heb ze weer eruit gehaald omdat het mij niet gelukt is. daarom heb ik de pagina die ik van internet heb gedownload erbij gepost. ik weet namelijk niet welke deel van het script ik moet invoegen en waar.
d