verstuurde mail in een tabel plaatsen
ik heb een contactform dat prima werkt met een php script.
alleen wil ik de resultaten van de ingevulde velden in een tabel verwerken zodat alles netjes uitgelijnd in de verstuurde mail komt staan.
Maar ik weet niet hoe ik dat moet doen, kan iemand mij hiermee helpen?
Dit is de code van het formulier
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
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
<?php if(isset($_POST['email'])) {
$email_to = "[email protected]";
$email_subject = "offerte ";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />"; echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['date']) ||
!isset($_POST['date1']) ||
!isset($_POST['name']) ||
!isset($_POST['adres']) ||
!isset($_POST['zippcode']) ||
!isset($_POST['place']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone']) ||
!isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$date = $_POST['date']; // not required
$date1 = $_POST['date1']; // not required
$name = $_POST['name']; // not required
$adres = $_POST['adres']; // not required
$zippcode = $_POST['zippcode']; // not required
$place = $_POST['place']; // not required
$email = $_POST['email']; // not required
$telephone = $_POST['telephone']; // not required
$comments = $_POST['comments']; // not required
$error_message = "";
$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
if(!eregi($email_exp,$email)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "^[a-z0-9 ,.'-]+$";
if(!eregi($string_exp,$date)) { $error_message .= 'The Date you entered does not appear to be valid.<br />';}
$string_exp = "^[a-z0-9 ,.'-]+$";
if(!eregi($string_exp,$date1)) { $error_message .= 'The Date1 you entered does not appear to be valid.<br />';}
$string_exp = "^[a-z0-9 .'-]+$";
if(!eregi($string_exp,$name)) { $error_message .= 'The Name you entered does not appear to be valid.<br />';}
$string_exp = "^[a-z0-9 .'-]+$";
if(!eregi($string_exp,$adres)) { $error_message .= 'The Adres you entered does not appear to be valid.<br />';}
$string_exp = "^[a-z0-9 .'-]+$";
if(!eregi($string_exp,$zippcode)) { $error_message .= 'The Zippcode you entered does not appear to be valid.<br />';}
$string_exp = "^[a-z0-9 .'-]+$";
if(!eregi($string_exp,$place)) { $error_message .= 'The Place you entered does not appear to be valid.<br />';}
$string_exp = "^[a-z0-9 .'-]+$";
if(!eregi($string_exp,$telephone)) { $error_message .= 'The Number you entered does not appear to be valid.<br />';}
$string_exp = "^[a-z0-9 .'-]+$";
if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />';}
if(strlen($error_message) > 0)
{ died($error_message); }
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Datum : ".clean_string($date)."\n";
$email_message .= "Datum feest : ".clean_string($date1)."\n";
$email_message .= "Naam : ".clean_string($name)."\n";
$email_message .= "Adres : ".clean_string($adres)."\n";
$email_message .= "Postcode : ".clean_string($zippcode)."\n";
$email_message .= "Woonplaats : ".clean_string($place)."\n";
$email_message .= "Email : ".clean_string($email)."\n";
$email_message .= "Telefoon : ".clean_string($telephone)."\n";
$email_message .= "opmerkingen : ".clean_string($comments)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?>
$email_to = "[email protected]";
$email_subject = "offerte ";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />"; echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['date']) ||
!isset($_POST['date1']) ||
!isset($_POST['name']) ||
!isset($_POST['adres']) ||
!isset($_POST['zippcode']) ||
!isset($_POST['place']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone']) ||
!isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$date = $_POST['date']; // not required
$date1 = $_POST['date1']; // not required
$name = $_POST['name']; // not required
$adres = $_POST['adres']; // not required
$zippcode = $_POST['zippcode']; // not required
$place = $_POST['place']; // not required
$email = $_POST['email']; // not required
$telephone = $_POST['telephone']; // not required
$comments = $_POST['comments']; // not required
$error_message = "";
$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
if(!eregi($email_exp,$email)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "^[a-z0-9 ,.'-]+$";
if(!eregi($string_exp,$date)) { $error_message .= 'The Date you entered does not appear to be valid.<br />';}
$string_exp = "^[a-z0-9 ,.'-]+$";
if(!eregi($string_exp,$date1)) { $error_message .= 'The Date1 you entered does not appear to be valid.<br />';}
$string_exp = "^[a-z0-9 .'-]+$";
if(!eregi($string_exp,$name)) { $error_message .= 'The Name you entered does not appear to be valid.<br />';}
$string_exp = "^[a-z0-9 .'-]+$";
if(!eregi($string_exp,$adres)) { $error_message .= 'The Adres you entered does not appear to be valid.<br />';}
$string_exp = "^[a-z0-9 .'-]+$";
if(!eregi($string_exp,$zippcode)) { $error_message .= 'The Zippcode you entered does not appear to be valid.<br />';}
$string_exp = "^[a-z0-9 .'-]+$";
if(!eregi($string_exp,$place)) { $error_message .= 'The Place you entered does not appear to be valid.<br />';}
$string_exp = "^[a-z0-9 .'-]+$";
if(!eregi($string_exp,$telephone)) { $error_message .= 'The Number you entered does not appear to be valid.<br />';}
$string_exp = "^[a-z0-9 .'-]+$";
if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />';}
if(strlen($error_message) > 0)
{ died($error_message); }
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Datum : ".clean_string($date)."\n";
$email_message .= "Datum feest : ".clean_string($date1)."\n";
$email_message .= "Naam : ".clean_string($name)."\n";
$email_message .= "Adres : ".clean_string($adres)."\n";
$email_message .= "Postcode : ".clean_string($zippcode)."\n";
$email_message .= "Woonplaats : ".clean_string($place)."\n";
$email_message .= "Email : ".clean_string($email)."\n";
$email_message .= "Telefoon : ".clean_string($telephone)."\n";
$email_message .= "opmerkingen : ".clean_string($comments)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" />
<link href="pics/apple-touch-icon.png" rel="apple-touch-icon" />
<meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script src="javascipt/functions.js" type="text/javascript"></script>
<title></title>
<meta content="iPod,iPhone,Webkit,iWebkit,Website,Create,mobile,Tutorial,free" name="Keywords" />
<meta content="" name="description" />
</head>
<body>
<div id="topbar">
<div id="leftnav">
<a href="index.html"><img alt="home" title="home" src="images/home.png" /></a></div>
<div id="title"> <img alt="plas"src="thumbs/recr.png" /></div>
<div id="rightbutton">
<a href="actueel.htm" title="Contact geslaagd">News</a></div>
</div>
<div id="content">
<span class="graytitle">Hartelijk dank!</span>
<ul class="pageitem">
<li class="textbox">
<p>Uw formulier is met succes verzonden.
</p>
</li>
</ul>
</div>
<div id="footer">
</div>
</body>
</html>
Wel HTML-headers versturen.
Maar even zoeken op "Send html mail with correct headers" zal je vast genoeg geven.
Regel 25 tot 33 is eigelijk overbodig $var kopieéren.
En weet niet of het op de manier jij het toepast schadelijk is.
Maar in PHP 5.3 is eregi() een functie die niet meer beschikbaar is.
Weet niet welke versie nu gedraait word bij jullie op moment. Maar bij versie 5.3 kan dit problemen opleveren.
Eddy Erkelens op 10/03/2012 15:35:03:
Prop het in een table?
Wel HTML-headers versturen.
Maar even zoeken op "Send html mail with correct headers" zal je vast genoeg geven.
Wel HTML-headers versturen.
Maar even zoeken op "Send html mail with correct headers" zal je vast genoeg geven.
Toevoeging op 10/03/2012 16:11:57:
@Eddy, het probleem is eigenlijk dat ik niet weet hoe ik de resultaten dus in een tabel krijg
Toevoeging op 10/03/2012 16:13:08:
en hoe die dan verwerkt moeten worden in de php mail?
Zit is mijn opmaak zoals het bij de ontvanger binnen komt.
Kijk hier eens na en probeer het toe te passen aan jou eigen script.
mocht je dan nog vragen hebben horen wij het graag op het forum.
Neem ook even mijn vorige topic nog even door.
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
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
<?php
// Headers
$headers = "From: \"Contact Formulier\" <".$ontvanger.">\r\n";
$headers .= "Reply-To: \"".$naam."\" <".$email.">\n";
$headers .= "Return-Path: Mail-Error <".$ontvanger.">\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$bericht = '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head></head>
<body>
<br />
<b>Naam:</b> '.$naam.'<br />
<b>Email:</b> <a href="mailto:'.$email.'">'.$email.'</a><br />
<br />
<b>Bericht:</b><br />
'.$bericht.'
<br />
</body>
</html>';
?>
// Headers
$headers = "From: \"Contact Formulier\" <".$ontvanger.">\r\n";
$headers .= "Reply-To: \"".$naam."\" <".$email.">\n";
$headers .= "Return-Path: Mail-Error <".$ontvanger.">\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$bericht = '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head></head>
<body>
<br />
<b>Naam:</b> '.$naam.'<br />
<b>Email:</b> <a href="mailto:'.$email.'">'.$email.'</a><br />
<br />
<b>Bericht:</b><br />
'.$bericht.'
<br />
</body>
</html>';
?>
Gewijzigd op 10/03/2012 16:29:29 door Frank WD
Frank WD op 10/03/2012 16:04:59:
Op regel 23 heb je died() staan moet zijn die().
Is niet waar.
Hij heeft zelf een function died() gemaakt.
Jij hebt gelijk, ik zie hem nu ook staan die function op regel 6.
Sorry voor deze foute vermelding.
Hartelijk dank voor de snelle reacties, ik ga ermee aan de slag en laat nog weten wat het geworden is! Groet
het is gelukt met de tabel in de verstuurde e-mail!
dank voor de informatie