e-mail script
De contact pagina werkt via een link naar een contact.php. Zie hieronder.
Als ik op de link klik krijg ik wel de melding "Uw bericht is correct verzonden!", maar ik ontvang geen mail.
Ik heb al wat rondgekeken hier, maar kan niet ontdekken waar het fout gaat.
(bij [email protected] vul ik mijn e-mail adres in)
Graag hulp.
M.vr.groeten
Adri
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?
$subject="from".$_GET['uw naam: '];
$headers= "From:".$_GET['e-mail: ']."\n";
$headers.='Content-type: text/html; charset=iso-8859-1';
mail($_GET['[email protected]'], $subject, "
<html>
<head>
<title>Contact letter</title>
</head>
<body>
<br>
".$_GET['bericht']."
</body>
</html>" , $headers);
echo ("Uw bericht is correct verzonden!");
?>
$subject="from".$_GET['uw naam: '];
$headers= "From:".$_GET['e-mail: ']."\n";
$headers.='Content-type: text/html; charset=iso-8859-1';
mail($_GET['[email protected]'], $subject, "
<html>
<head>
<title>Contact letter</title>
</head>
<body>
<br>
".$_GET['bericht']."
</body>
</html>" , $headers);
echo ("Uw bericht is correct verzonden!");
?>
<script>
resizeTo(300, 300)
//window.close()
</script>
Probeer
Adri Rovers op 18/03/2014 14:53:32:
Ik heb met behulp van een template een website aan het maken, wat goed lukt.
De contact pagina werkt via een link naar een contact.php. Zie hieronder.
Als ik op de link klik krijg ik wel de melding "Uw bericht is correct verzonden!", maar ik ontvang geen mail.
Ik heb al wat rondgekeken hier, maar kan niet ontdekken waar het fout gaat.
(bij [email protected] vul ik mijn e-mail adres in)
Graag hulp.
M.vr.groeten
Adri
<script>
resizeTo(300, 300)
//window.close()
</script>
De contact pagina werkt via een link naar een contact.php. Zie hieronder.
Als ik op de link klik krijg ik wel de melding "Uw bericht is correct verzonden!", maar ik ontvang geen mail.
Ik heb al wat rondgekeken hier, maar kan niet ontdekken waar het fout gaat.
(bij [email protected] vul ik mijn e-mail adres in)
Graag hulp.
M.vr.groeten
Adri
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?
$subject="from".$_GET['uw naam: '];
$headers= "From:".$_GET['e-mail: ']."\n";
$headers.='Content-type: text/html; charset=iso-8859-1';
mail($_GET['[email protected]'], $subject, "
<html>
<head>
<title>Contact letter</title>
</head>
<body>
<br>
".$_GET['bericht']."
</body>
</html>" , $headers);
echo ("Uw bericht is correct verzonden!");
?>
$subject="from".$_GET['uw naam: '];
$headers= "From:".$_GET['e-mail: ']."\n";
$headers.='Content-type: text/html; charset=iso-8859-1';
mail($_GET['[email protected]'], $subject, "
<html>
<head>
<title>Contact letter</title>
</head>
<body>
<br>
".$_GET['bericht']."
</body>
</html>" , $headers);
echo ("Uw bericht is correct verzonden!");
?>
<script>
resizeTo(300, 300)
//window.close()
</script>
Er gaat een hoop mis met je script.
Zo is $_GET['uw_naam :'] niet correct. En waarom deze als onderwerp?
$_GET['e-mail: '] is dus ook onjuist.
$_GET['[email protected]'] kan ook niet.
Wat GET doet is de waarde uit je URL halen.
Bijvoorbeeld
URL: index.php?naam=Adri
Op index kun je de naam dan ophalen met $_GET['naam'].
Je mist een aantal headers en je controleert niet of het daadwerkelijk goed gaat.
Sowieso zou ik POST gebruiken i.p.v. GET
Gewijzigd op 18/03/2014 15:08:19 door Michael -
Ja helemaal nieuw met PHP. Dat script zat bij de template,
Ik kan je het wel voordoen maar daar leer je ook niks van.
ik heb nu dit gemaakt, vul alle velden in, maar krijg toch het bericht "U heeft niet alle velden ingevuld" en ook geen mail. De velden komen overeen met die in 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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
if (!isset($_POST['naam']) || !isset($_POST['bedrijf']) ||!isset($_POST['telefoon']) ||!isset($_POST['email']) || !isset($_POST['bericht'])) {
echo 'U heeft niet alle velden ingevuld!';
exit;
}
$naam = htmlspecialchars($_POST['naam']);
$bedrijf = htmlspecialchars($_POST['bedrijf']);
$email = htmlspecialchars($_POST['email']);
$bericht = htmlspecialchars($_POST['bericht']);
$tijd = time();
$datum = strftime('%d/%m/%y %H:%M', $tijd);
$ip = getenv('REMOTE_ADDR');
$message = $naam.' met het e-mailadres '.$email.' en het IP '.$ip.' stuurde op '.$datum.' het volgende bericht:
____________________________________
'.$bericht.'
------------------------------------';
mail('[email protected]', 'Bericht van mail.nl', $message, 'From: '.$email);
echo 'Uw bericht is verzonden. U krijgt zo snel mogelijk antwoord.';
?>
if (!isset($_POST['naam']) || !isset($_POST['bedrijf']) ||!isset($_POST['telefoon']) ||!isset($_POST['email']) || !isset($_POST['bericht'])) {
echo 'U heeft niet alle velden ingevuld!';
exit;
}
$naam = htmlspecialchars($_POST['naam']);
$bedrijf = htmlspecialchars($_POST['bedrijf']);
$email = htmlspecialchars($_POST['email']);
$bericht = htmlspecialchars($_POST['bericht']);
$tijd = time();
$datum = strftime('%d/%m/%y %H:%M', $tijd);
$ip = getenv('REMOTE_ADDR');
$message = $naam.' met het e-mailadres '.$email.' en het IP '.$ip.' stuurde op '.$datum.' het volgende bericht:
____________________________________
'.$bericht.'
------------------------------------';
mail('[email protected]', 'Bericht van mail.nl', $message, 'From: '.$email);
echo 'Uw bericht is verzonden. U krijgt zo snel mogelijk antwoord.';
?>
Om te controleren of een formulier wordt gepost doe je met if($_SERVER['REQUEST_METHOD'] == 'POST')
Probeer onderstaande code eens.
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
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
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['naam'],$_POST['bedrijf'],$_POST['telefoon'],$_POST['email'],$_POST['bericht'])) {
$naam = htmlspecialchars($_POST['naam']);
$bedrijf = htmlspecialchars($_POST['bedrijf']);
$email = htmlspecialchars($_POST['email']);
$bericht = htmlspecialchars($_POST['bericht']);
$tijd = time();
$datum = strftime('%d/%m/%y %H:%M', $tijd);
$ip = getenv('REMOTE_ADDR');
$message = $naam.' met het e-mailadres '.$email.' en het IP '.$ip.' stuurde op '.$datum.' het volgende bericht:
____________________________________
'.$bericht.'
------------------------------------';
if(mail('[email protected]', 'Bericht van mail.nl', $message, 'From: '.$email)) {
echo 'Uw bericht is verzonden. U krijgt zo snel mogelijk antwoord.';
} else {
echo 'Uw bericht kon niet worden verzonden. Probeer het later eens.';
}
} else {
echo 'Er is iets fout gegaan';
}
}
?>
<form method="POST">
<label>Naam</label>
<input type="text" name="naam" /><br />
<label>Bedrijf</label>
<input type="text" name="bedrijf" /><br />
<label>Telefoonnummer</label>
<input type="tel" name="telefoon" /><br />
<label>E-mailadres</label>
<input type="email" name="email" /><br />
<label>Bericht</label>
<textarea name="bericht"></textarea>
<button>Verzenden</button>
</form>
if($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['naam'],$_POST['bedrijf'],$_POST['telefoon'],$_POST['email'],$_POST['bericht'])) {
$naam = htmlspecialchars($_POST['naam']);
$bedrijf = htmlspecialchars($_POST['bedrijf']);
$email = htmlspecialchars($_POST['email']);
$bericht = htmlspecialchars($_POST['bericht']);
$tijd = time();
$datum = strftime('%d/%m/%y %H:%M', $tijd);
$ip = getenv('REMOTE_ADDR');
$message = $naam.' met het e-mailadres '.$email.' en het IP '.$ip.' stuurde op '.$datum.' het volgende bericht:
____________________________________
'.$bericht.'
------------------------------------';
if(mail('[email protected]', 'Bericht van mail.nl', $message, 'From: '.$email)) {
echo 'Uw bericht is verzonden. U krijgt zo snel mogelijk antwoord.';
} else {
echo 'Uw bericht kon niet worden verzonden. Probeer het later eens.';
}
} else {
echo 'Er is iets fout gegaan';
}
}
?>
<form method="POST">
<label>Naam</label>
<input type="text" name="naam" /><br />
<label>Bedrijf</label>
<input type="text" name="bedrijf" /><br />
<label>Telefoonnummer</label>
<input type="tel" name="telefoon" /><br />
<label>E-mailadres</label>
<input type="email" name="email" /><br />
<label>Bericht</label>
<textarea name="bericht"></textarea>
<button>Verzenden</button>
</form>
In eerste instantie werkte het nog niet. Heb nu een deel van de template gewijzigd in:
Code (php)
1
2
3
4
5
6
7
2
3
4
5
6
7
<br><form name="form1" method="post" action="contact.php">
Naam: <br><input name="naam" type="text" value size="50"""><br>
Bedrijf: <br><input name="bedrijf" type="text" value size="50"""><br> Telefoon: <br><input name="telefoon" type="text" value size="50"""><br>
E-mail: <br><input name="email" type="text" value="value" size="50"><br><br>
<textarea name="bericht" rows="7" cols="50">value</textarea><br>
<input type="submit" name="Submit" value="Verzenden">
</form>
Naam: <br><input name="naam" type="text" value size="50"""><br>
Bedrijf: <br><input name="bedrijf" type="text" value size="50"""><br> Telefoon: <br><input name="telefoon" type="text" value size="50"""><br>
E-mail: <br><input name="email" type="text" value="value" size="50"><br><br>
<textarea name="bericht" rows="7" cols="50">value</textarea><br>
<input type="submit" name="Submit" value="Verzenden">
</form>
Het bericht wordt nu keurig verzonden.
Onder de tekst "Uw bericht is verzonden. U krijgt zo snel mogelijk antwoord." verschijnt nu weer het (niet opgemaakte) formulier.
Ik zou willen dat dat niet gebeurt, maar dat er weer teruggegaan wordt naar contact.html
Hoe krijg ik dat nog voor elkaar.
Toevoeging op 18/03/2014 18:19:08:
Toch zou het het mooist zijn als ik de template kan blijven gebruiken:
de HTML code daarvan is en de bedleoing is dat als ik op send klik het ingevulde formulier wordt verstuurd.
Met de code van Michael krijg ik dat niet voor elkaar.
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
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
Vul al uw gegevens in, zodat we u zo goed mogelijk kunnen helpen.<br>
<br style="line-height:9px">
<form action="" enctype="multipart/form-data" id="form">
<table cellspacing="0" cellpadding="0" class="form">
<tr>
<td style="width:198px; height:128px">
<table cellspacing="0" cellpadding="0">
<tr>
<td style="width:198px; height:27px"><input name="naam" type="text" id="naam" value="naam"></td>
</tr>
<tr>
<td style="width:198px; height:27px"><input name="bedrijf" type="text" id="bedrijf" value="bedrijf"></td>
</tr>
<tr>
<td style="width:198px; height:27px"><input name="telefoon" type="text" id="telefoon" value="tefefoon"></td>
</tr>
<tr>
<td style="width:198px; height:27px"><input name="email" type="text" id="email" value="email"></td>
</tr>
</table>
</td>
<td style="width:202px; height:128px">
<table cellspacing="0" cellpadding="0">
<tr>
<td style="width:202px; height:109px"><textarea name="bericht" cols="0" rows="0" id="bericht">bericht</textarea></td>
</tr>
<tr>
<td style="width:202px; height:19px">
<br style="line-height:1px">
<img src="images/spacer.gif" alt="" width="116" height="1"><strong><a href="#" onClick="document.getElementById('form').reset()">reset</a></strong><img src="images/spacer.gif" alt="" width="15" height="1"><strong><a href="contact.php" onClick="document.getElementById('form').submit()">send</a></strong>
<br style="line-height:9px">
<form action="" enctype="multipart/form-data" id="form">
<table cellspacing="0" cellpadding="0" class="form">
<tr>
<td style="width:198px; height:128px">
<table cellspacing="0" cellpadding="0">
<tr>
<td style="width:198px; height:27px"><input name="naam" type="text" id="naam" value="naam"></td>
</tr>
<tr>
<td style="width:198px; height:27px"><input name="bedrijf" type="text" id="bedrijf" value="bedrijf"></td>
</tr>
<tr>
<td style="width:198px; height:27px"><input name="telefoon" type="text" id="telefoon" value="tefefoon"></td>
</tr>
<tr>
<td style="width:198px; height:27px"><input name="email" type="text" id="email" value="email"></td>
</tr>
</table>
</td>
<td style="width:202px; height:128px">
<table cellspacing="0" cellpadding="0">
<tr>
<td style="width:202px; height:109px"><textarea name="bericht" cols="0" rows="0" id="bericht">bericht</textarea></td>
</tr>
<tr>
<td style="width:202px; height:19px">
<br style="line-height:1px">
<img src="images/spacer.gif" alt="" width="116" height="1"><strong><a href="#" onClick="document.getElementById('form').reset()">reset</a></strong><img src="images/spacer.gif" alt="" width="15" height="1"><strong><a href="contact.php" onClick="document.getElementById('form').submit()">send</a></strong>
Gewijzigd op 19/03/2014 10:17:37 door - Ariën -
Maar goed. Volgens mij is je template 'contact.html' ? Hierin kun je geen PHP gebruiken.
De enige optie is dan, zoals je nou al doet, verwijzen naar contact.php, met het gevolg dat je op een andere pagina komt. De pagina even aanroepen en toch op de html pagina blijven kan alleen met Javascript, maar dat lijkt me nou nog een stap te ver voor je?
Waarom wil je je vasthouden aan het template? Is dit niet om te zetten naar contact.php? (Hernoemen en links verwijzen naar de php pagina).
Na invullen en verzenden blijf ik keurig op de pagina, maar er gebeurt niets.
Ik krijg geen mail. De code is nu als volgt:
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
130
131
132
133
134
135
136
137
138
139
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
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE></TITLE>
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<LINK HREF="style.css" TYPE="text/css" REL="stylesheet">
</HEAD>
<BODY>
<table cellspacing="0" cellpadding="0" align="center">
<tr>
<td style="width:766px; height:780px">
<table cellspacing="0" cellpadding="0">
<tr>
<td style="width:42px; height:780px"></td>
<td style="width:676px; height:780px">
<table cellspacing="0" cellpadding="0">
<tr>
<td style="width:676px; height:119px; background-image: url(images/grey_bg.gif); background-repeat:no-repeat">
<table cellspacing="0" cellpadding="0">
<tr>
<td style="width:560px; height:119px">
<br style="line-height:48px">
<img src="images/c-name2.jpg" alt="" hspace="3">
</td>
<td style="width:116px; height:119px">
<br style="line-height:66px">
<a href="welkom.html"><img src="images/link.gif" alt="" style="margin-right:18px" border="0"></a><a href="#"><img src="images/link1.gif" alt="" style="margin-right:21px" border="0"></a><a href="#"><img src="images/link2.gif" alt="" border="0"></a> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="width:676px; height:563px">
<table cellspacing="0" cellpadding="0">
<tr>
<td style="width:226px; height:563px">
<a href="index.html"><img src="images/back.gif" alt="" border="0"></a><img src="images/pic5_1.gif" alt=""><br>
<img src="images/pic5_2.gif" alt=""><br>
<a href="werkwijze.html"><img src="images/comp2.gif" alt="" border="0"></a><a href="diensten.html"><img src="images/srv2.gif" alt="" border="0"></a><br>
<a href="projecten.html"><img src="images/sol2.gif" alt="" border="0"></a><a href="index-5.html"><img src="images/cont2.gif" alt="" border="0"></a><br> </td>
<td style="width:450px; height:563px; background-color:#F8F8F8; background-image:url(images/top.gif); background-repeat:no-repeat">
<table cellspacing="0" cellpadding="0">
<tr>
<td style="width:450px; height:563px; background-image:url(images/bottom.gif); background-repeat:no-repeat; background-position: left bottom" class="list">
<br style="line-height:30px">
<img src="images/title5_1.gif" alt="" style="margin-left:29px"><br>
<br style="line-height:9px">
<img src="images/pic5_3.gif" alt="" align="left" style="margin-left:30px; margin-top:2px; margin-right:14px"><strong>Lenoir
Exclusief Houtwerk
</strong><br>
<span class="list" style="width: 450px; height: 563px; background-image: url(images/bottom.gif); background-repeat: no-repeat; background-position: left bottom; color: #7F7F7F;">t 49 - xxxx EB xxxx</span><br>
<br style="line-height:12px">
<span class="list" style="width: 450px; height: 563px; background-image: url(images/bottom.gif); background-repeat: no-repeat; background-position: left bottom; color: #7F7F7F;">Mobiel : +31 611077787</span><br>
<span class="list" style="width: 450px; height: 563px; background-image: url(images/bottom.gif); background-repeat: no-repeat; background-position: left bottom; color: #7F7F7F;">Telefoon: +31 162692796</span><br>
<br>
<br style="line-height:26px">
<img src="images/px2_1.gif" alt="" style="margin-left:29px"><br>
<br style="line-height:25px">
<br>
<br style="line-height:14px">
<img src="images/px2_1.gif" alt="" style="margin-left:29px"><br>
<br style="line-height:24px">
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['naam'],$_POST['bedrijf'],$_POST['telefoon'],$_POST['email'],$_POST['bericht'])) {
$naam = htmlspecialchars($_POST['naam']);
$bedrijf = htmlspecialchars($_POST['bedrijf']);
$email = htmlspecialchars($_POST['email']);
$bericht = htmlspecialchars($_POST['bericht']);
$tijd = time();
$datum = strftime('%d/%m/%y %H:%M', $tijd);
$ip = getenv('REMOTE_ADDR');
$message = $naam.' met het e-mailadres '.$email.' en het IP '.$ip.' stuurde op '.$datum.' het volgende bericht:
____________________________________
'.$bericht.'
------------------------------------';
if(mail('mijnmail@@gmail.com', 'Bericht van mail.nl', $message, 'From: '.$email)) {
echo 'Uw bericht is verzonden. U krijgt zo snel mogelijk antwoord.';
} else {
echo 'Uw bericht kon niet worden verzonden. Probeer het later eens.';
}
} else {
echo 'Er is iets fout gegaan';
}
}
?>
<form method="POST">
<label>Naam</label>
<input type="text" name="naam" /><br />
<label>Bedrijf</label>
<input type="text" name="bedrijf" /><br />
<label>Telefoonnummer</label>
<input type="tel" name="telefoon" /><br />
<label>E-mailadres</label>
<input type="email" name="email" /><br />
<label>Bericht</label>
<textarea name="bericht"></textarea>
<button>Verzenden</button>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="width:676px; height:98px" class="policy">
<br style="line-height:45px">
<span class="policy" style="width:676px; height:99px"> ef Houtwerk © 2014</span></td>
</tr>
</table>
</td>
<td style="width:48px; height:780px"></td>
</tr>
</table>
</td>
</tr>
</table>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE></TITLE>
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<LINK HREF="style.css" TYPE="text/css" REL="stylesheet">
</HEAD>
<BODY>
<table cellspacing="0" cellpadding="0" align="center">
<tr>
<td style="width:766px; height:780px">
<table cellspacing="0" cellpadding="0">
<tr>
<td style="width:42px; height:780px"></td>
<td style="width:676px; height:780px">
<table cellspacing="0" cellpadding="0">
<tr>
<td style="width:676px; height:119px; background-image: url(images/grey_bg.gif); background-repeat:no-repeat">
<table cellspacing="0" cellpadding="0">
<tr>
<td style="width:560px; height:119px">
<br style="line-height:48px">
<img src="images/c-name2.jpg" alt="" hspace="3">
</td>
<td style="width:116px; height:119px">
<br style="line-height:66px">
<a href="welkom.html"><img src="images/link.gif" alt="" style="margin-right:18px" border="0"></a><a href="#"><img src="images/link1.gif" alt="" style="margin-right:21px" border="0"></a><a href="#"><img src="images/link2.gif" alt="" border="0"></a> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="width:676px; height:563px">
<table cellspacing="0" cellpadding="0">
<tr>
<td style="width:226px; height:563px">
<a href="index.html"><img src="images/back.gif" alt="" border="0"></a><img src="images/pic5_1.gif" alt=""><br>
<img src="images/pic5_2.gif" alt=""><br>
<a href="werkwijze.html"><img src="images/comp2.gif" alt="" border="0"></a><a href="diensten.html"><img src="images/srv2.gif" alt="" border="0"></a><br>
<a href="projecten.html"><img src="images/sol2.gif" alt="" border="0"></a><a href="index-5.html"><img src="images/cont2.gif" alt="" border="0"></a><br> </td>
<td style="width:450px; height:563px; background-color:#F8F8F8; background-image:url(images/top.gif); background-repeat:no-repeat">
<table cellspacing="0" cellpadding="0">
<tr>
<td style="width:450px; height:563px; background-image:url(images/bottom.gif); background-repeat:no-repeat; background-position: left bottom" class="list">
<br style="line-height:30px">
<img src="images/title5_1.gif" alt="" style="margin-left:29px"><br>
<br style="line-height:9px">
<img src="images/pic5_3.gif" alt="" align="left" style="margin-left:30px; margin-top:2px; margin-right:14px"><strong>Lenoir
Exclusief Houtwerk
</strong><br>
<span class="list" style="width: 450px; height: 563px; background-image: url(images/bottom.gif); background-repeat: no-repeat; background-position: left bottom; color: #7F7F7F;">t 49 - xxxx EB xxxx</span><br>
<br style="line-height:12px">
<span class="list" style="width: 450px; height: 563px; background-image: url(images/bottom.gif); background-repeat: no-repeat; background-position: left bottom; color: #7F7F7F;">Mobiel : +31 611077787</span><br>
<span class="list" style="width: 450px; height: 563px; background-image: url(images/bottom.gif); background-repeat: no-repeat; background-position: left bottom; color: #7F7F7F;">Telefoon: +31 162692796</span><br>
<br>
<br style="line-height:26px">
<img src="images/px2_1.gif" alt="" style="margin-left:29px"><br>
<br style="line-height:25px">
<br>
<br style="line-height:14px">
<img src="images/px2_1.gif" alt="" style="margin-left:29px"><br>
<br style="line-height:24px">
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['naam'],$_POST['bedrijf'],$_POST['telefoon'],$_POST['email'],$_POST['bericht'])) {
$naam = htmlspecialchars($_POST['naam']);
$bedrijf = htmlspecialchars($_POST['bedrijf']);
$email = htmlspecialchars($_POST['email']);
$bericht = htmlspecialchars($_POST['bericht']);
$tijd = time();
$datum = strftime('%d/%m/%y %H:%M', $tijd);
$ip = getenv('REMOTE_ADDR');
$message = $naam.' met het e-mailadres '.$email.' en het IP '.$ip.' stuurde op '.$datum.' het volgende bericht:
____________________________________
'.$bericht.'
------------------------------------';
if(mail('mijnmail@@gmail.com', 'Bericht van mail.nl', $message, 'From: '.$email)) {
echo 'Uw bericht is verzonden. U krijgt zo snel mogelijk antwoord.';
} else {
echo 'Uw bericht kon niet worden verzonden. Probeer het later eens.';
}
} else {
echo 'Er is iets fout gegaan';
}
}
?>
<form method="POST">
<label>Naam</label>
<input type="text" name="naam" /><br />
<label>Bedrijf</label>
<input type="text" name="bedrijf" /><br />
<label>Telefoonnummer</label>
<input type="tel" name="telefoon" /><br />
<label>E-mailadres</label>
<input type="email" name="email" /><br />
<label>Bericht</label>
<textarea name="bericht"></textarea>
<button>Verzenden</button>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="width:676px; height:98px" class="policy">
<br style="line-height:45px">
<span class="policy" style="width:676px; height:99px"> ef Houtwerk © 2014</span></td>
</tr>
</table>
</td>
<td style="width:48px; height:780px"></td>
</tr>
</table>
</td>
</tr>
</table>
</BODY>
</HTML>
- Aar -:
Gelieve in het vervolg bij code de [code][/code]-tags gebruiken.
Alvast bedankt!
Alvast bedankt!
Gewijzigd op 19/03/2014 10:16:54 door - Ariën -
Krijg je ook niet de melding of de mail wel of niet verzonden is?
Het is soms ook handig om foutmeldingen weer te geven. Dit doe je door de volgende code op de eerste regels te zetten
graag straks ook nog even controleren of $email een (1!!) mail adres bevat.
En met name dat er geen enters in $email staan, want dan is je script vatbaar voor mail header manipulatie en wordt je server zo gebruikt om spam te versturen
Boven het formulier stond "Uw bericht kon niet worden verzonden. Probeer het later eens. "
Mijn email adres gecontroleerd en daar stond de fout (twee keer een @).
Alles gaat nu zoals ik het wilde.
Bedankt voor je hulp.
@Ivo P
Bedankt, er staat nu een correct email adres.
dus niet meer rechtstreeks het email adres uit $_POST wat de gebruiker heeft ingevoerd
Houd rekening met de (juiste) headers om een mail te versturen!