Goedendag,
Ik ben op dit moment bezig met een nieuwsbrief voor een website, dit is mijn code:
Zoals jullie in de onderstaande code zien, maak ik gebruik van ob_start om mijn code van de nieuwsbrief te includen, dit zodat er niet letterlijk php code wordt verzonden, maar dat de code eerst wordt gegenereerd.
nieuwsbriefmail.php
nieuwsbrief.php
Zoals sommige misschien is opgevallen is deze nieuwsbrief voor een erotische site. In de nieuwsbrief moeten nieuwste amateurs, nieuwste video's EN favorieten mee worden gestuurd. De favorieten is voor iedere gebruiker, waarnaar de mail wordt gezonden, uniek. Tenslotte heeft niet iedereen dezelfde favorieten.
Zoals jullie vast was opgevallen wil ik dit oplossen door in de nieuwsbriefmail.php een while loop te zetten die alle gebruikers doorloopt, en IN deze while loop steeds opnieuw de nieuwsbrief.php includen, zodat ik in nieuwsbrief.php code kan plaatsen die favorieten selecteerd aan de hand van de gebruiker die op dat moment geselecteerd is. En hier gaat het fout!
Als ik de ob_start buiten de while loop plaats, dan gaat het goed, maar dan krijgt iedereen natuurlijk dezelfde favorieten, omdat ik niet per gebruiker de favorieten kan selecteren. Stop ik hem IN de while loop (zoals bovenstaande code) dan wordt de mail ALLEEN naar de eerste die voorkomt in de database verzonden, en niet naar iedereen.
Weet iemand hoe ik dit kan oplossen?
Alvast vriendelijk bedankt,
Mvg,
Erik
Ik ben op dit moment bezig met een nieuwsbrief voor een website, dit is mijn code:
Zoals jullie in de onderstaande code zien, maak ik gebruik van ob_start om mijn code van de nieuwsbrief te includen, dit zodat er niet letterlijk php code wordt verzonden, maar dat de code eerst wordt gegenereerd.
nieuwsbriefmail.php
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
| <?php error_reporting(E_ALL); ini_set("display_errors", 1); $db=mysql_connect("localhost", "**", "**"); mysql_select_db("amapvtest"); $query = ("SELECT * FROM lid WHERE soort='L'"); $resultaat = mysql_query($query) or die ("FOUT: " .mysql_error()); while ($record = mysql_fetch_object($resultaat)){ //bevestigingsemail //vaste gegevens $gebruikersnaam = $record->gebruikersnaam; $Naar = $record->email; include_once('class.phpmailer.php'); $mail = new PHPMailer(); ob_start(); include_once 'nieuwsbrief.php'; $body = ob_get_contents(); ob_end_clean(); $subject = 'testmail';//_AANM_ACTIVATIEMAIL; $body = eregi_replace("[\]",'',$body); $subject = eregi_replace("[\]",'',$subject); $mail->From = "info@betterlook.net";//_ALG_SUPADRES; $mail->FromName = 'test';//_ALG_MAILNAAM; $mail->Subject = $subject; $mail->AltBody = html_entity_decode(strip_tags($body)); // optional, comment out and test $mail->MsgHTML($body); $mail->AddAddress($Naar); if(!$mail->Send()) { echo 'mislukt';//_AANM_AANGEMELD1; } else { echo 'gelukt';//_AANM_AANGEMELD2; } } ?> |
nieuwsbrief.php
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
| <?php $db=mysql_connect("localhost", "**", "**"); mysql_select_db("amapvtest"); $lid = 2; function age2($date){ $year = substr($date,0,4); $month = substr($date,5,2); $day = substr($date,8,2); $year_diff = date("Y") - $year; $month_diff = date("m") - $month; $day_diff = date("d") - $day; if ($month_diff < 0 | ($month_diff == 0 && $day_diff < 0)) { $year_diff--;} return $year_diff; } ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body style="background:#FFFFFF; margin:0; padding:0;"> <!-- Begin nieuwsbrief --> <div style="text-align:center"> <!-- header --> <div style="width:600px; height:118px; margin-top:20px;"> <img src="amateursprive.png" /> </div> <!-- center --> <table width="600px" align="center" cellspacing="0" cellpadding="0"> <tr> <td background="center.png" style="background-repeat:repeat-y;"> <!--<div style="background-image:url(center.png); background-repeat:repeat-y; border:solid #FFFFFF; border-right:0px; border-top:0px; border-left:0px; border-bottom:0px; width:600px;">--> <!-- inleiding --> <div style="font-size:12px; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; color:#666666; text-align:left; margin-left:8px;"><br /> <table width="584px"> <tr> <td colspan="2" style="text-align:left;"> <h1 style='font-family: Georgia, "Times New Roman", Times, serif; font-size:18px; font-weight: normal; color: #000000; border-left:3px solid; border-color:#666666;'> Nieuwe Amateurs</h1> </td> </tr> <tr> <?php $i = 0; $query = ("SELECT * FROM lid WHERE soort = 'A' AND TO_DAYS(NOW()) - TO_DAYS(amateurdatum)<=31 AND eersteitemdatum IS NOT NULL"); $resultaat = mysql_query($query) or die ("FOUT: " .mysql_error()); while ($record = mysql_fetch_object($resultaat)){ $Leeftijd = age2($record->amateurdatum); echo '<td style="text-align:center; background:#FFCCCC; border:#FF9933 solid 1px; height:150px; width:100px; font-size:12px; vertical-align:top;">'; echo '<img src="images/profielfotos/'; echo $record->id; echo '.jpg" style="margin:5px; border:solid 3px #FFFFFF; text-align:center;" height="100px" /><br />'; echo '<b>'; echo $record->gebruikersnaam; echo '</b><br>'; echo 'Leeftijd:'; echo $Leeftijd; echo '</td>'; $i++; if ($i<5){ echo '<td width="100%"> </td>'; } if ($i == 5){ echo '</tr><tr>'; $i = 0; } } ?> </tr> </table> <br /><br /> <!-- favorites --> <div style="text-align:left; margin-top:20px;"> <h1 style='font-family: Georgia, "Times New Roman", Times, serif; font-size:18px; font-weight: normal; color: #000000; border-left:3px solid; border-color:#666666;'> Favorieten</h1> <div style="background-color:#feebda; border-top:solid #FF9933 1px; border-bottom:solid #FF9933 1px; width:584px"> <table style="margin-left:8px; width:550px; vertical-align:top;"> <?php $query = ("SELECT * FROM favorieten INNER JOIN lid ON favorieten.amateurid = lid.id WHERE lidid ='".$lid."'"); $resultaat = mysql_query($query) or die ("FOUT: " .mysql_error()); while ($record = mysql_fetch_object($resultaat)){ $amateur = $record->amateurid; echo '<tr><td>'; echo '<img src="images/profielfotos/'; echo $amateur; echo '.jpg" height="100px" style="border:solid 3px #FFFFFF;" /></td>'; echo '<td style="padding-left:35px; font-size:12px; text-align:left; vertical-align:top;" height="10px">'; echo '<h5>'; echo $record->gebruikersnaam; echo '</h5>Geslacht:'; if ($record->geslacht = 'V'){ echo 'Vrouw'; }else{ echo 'Man'; } echo '<br />Leeftijd:'; echo $Leeftijd; echo '<br /></td>'; echo '<td style="padding-left:35px; font-size:12px; text-align:left; vertical-align:top;">'; echo '<h5 style="color:#FF66CC;">'; echo "Nieuwe Video's</h5>"; $query = ("SELECT * FROM item WHERE amateurid = '".$amateur."' AND TO_DAYS(NOW()) - TO_DAYS(datumtijd)<=31"); $resultaat = mysql_query($query) or die ("FOUT: " .mysql_error()); while ($record = mysql_fetch_object($resultaat)){ echo '<a style="text-decoration:none;" href="#">'; echo $record->naam; echo '('; echo $record->speelduur; echo 'sec.)</a><br />'; echo '<a style="text-decoration:none;" href="#">'; echo 'Sex op het Werk (25 min)</a>'; } echo '</td><td style="padding-left:35px; font-size:12px; text-align:left; vertical-align:top;">'; echo '<h5 style="color:#FF66CC;">Nieuwe Foto'; echo "'s</h5>"; echo '<a style="text-decoration:none;" href="#">Brutal Quickie (12)</a><br />'; echo '<a style="text-decoration:none;" href="#">Het bed Opmaken (20)</a><br />'; echo '<a style="text-decoration:none;" href="#">Wiedervereinigug (10)</a><br />'; echo '<a style="text-decoration:none;" href="#">Opwindende Kwelling (15)</a><br />'; echo '</td></tr>'; } ?> </table> </div> </div> <br /><br /> <table width="583px"> <tr> <td colspan="2" style="text-align:left;"> <h1 style='font-family: Georgia, "Times New Roman", Times, serif; font-size:18px; font-weight: normal; color: #000000; border-left:3px solid; border-color:#666666;'> Nieuwste Video's</h1> </td> </tr> <tr> <td width="10%" style="background:#FFCCCC; border:#FF9933 solid 1px; height:150px; font-size:12px; vertical-align:top; text-align:center;"> <img src="3357.jpg" style="margin:5px; border:solid 3px #FFFFFF; text-align:center;" height="100px" /><br /> <b>SMcouple (koppel)</b><br> Naam video: <a style="text-decoration:none;" href="#">Sexlessen bij Lerares Linda</a><br /> Speelduur: 25 minuten </td> <td width="10%" style="background:#FFCCCC; border:#FF9933 solid 1px; height:150px; font-size:12px; vertical-align:top; text-align:center;"> <img src="3357.jpg" style="margin:5px; border:solid 3px #FFFFFF; text-align:center;" height="100px" /><br /> <b>SMcouple (koppel)</b><br> Naam video: <a style="text-decoration:none;" href="#">Sexlessen bij Lerares Linda</a><br /> Speelduur: 25 minuten </td> <td width="10%" style="background:#FFCCCC; border:#FF9933 solid 1px; height:150px; font-size:12px; vertical-align:top; text-align:center;"> <img src="3357.jpg" style="margin:5px; border:solid 3px #FFFFFF; text-align:center;" height="100px" /><br /> <b>SMcouple (koppel)</b><br> Naam video: <a style="text-decoration:none;" href="#">Sexlessen bij Lerares Linda</a><br /> Speelduur: 25 minuten </td> <td width="10%" style="background:#FFCCCC; border:#FF9933 solid 1px; height:150px; font-size:12px; vertical-align:top; text-align:center;"> <img src="3357.jpg" style="margin:5px; border:solid 3px #FFFFFF; text-align:center;" height="100px" /><br /> <b>SMcouple (koppel)</b><br> Naam video: <a style="text-decoration:none;" href="#">Sexlessen bij Lerares Linda</a><br /> Speelduur: 25 minuten </td> </tr> </table> </div> </td> </tr> </table> <table background="bottom.png" width="600px" height="70px" style="text-align:center; font-family:Georgia, 'Times New Roman', Times, serif; font-style:italic; font-size:12px; color:#FFFFFF;" cellpadding="0" cellspacing="0"> <tr> <td style="text-align:center" colspan="4"> De populairste amateurs op amateursprive.nl:<br /> </td> </tr> <tr> <td> Annelie Bankers<br /> Peter van Oss<br /> </td> <td> Rik Slegers<br /> Johan de Vries<br /> </td> <td> Monique van Bakel<br /> Vera Venhuizen<br /> </td> <td> Eva Buis<br /> Esther Naaktgeboren<br /> </td> </tr> </table> </body> </html> |
Zoals sommige misschien is opgevallen is deze nieuwsbrief voor een erotische site. In de nieuwsbrief moeten nieuwste amateurs, nieuwste video's EN favorieten mee worden gestuurd. De favorieten is voor iedere gebruiker, waarnaar de mail wordt gezonden, uniek. Tenslotte heeft niet iedereen dezelfde favorieten.
Zoals jullie vast was opgevallen wil ik dit oplossen door in de nieuwsbriefmail.php een while loop te zetten die alle gebruikers doorloopt, en IN deze while loop steeds opnieuw de nieuwsbrief.php includen, zodat ik in nieuwsbrief.php code kan plaatsen die favorieten selecteerd aan de hand van de gebruiker die op dat moment geselecteerd is. En hier gaat het fout!
Als ik de ob_start buiten de while loop plaats, dan gaat het goed, maar dan krijgt iedereen natuurlijk dezelfde favorieten, omdat ik niet per gebruiker de favorieten kan selecteren. Stop ik hem IN de while loop (zoals bovenstaande code) dan wordt de mail ALLEEN naar de eerste die voorkomt in de database verzonden, en niet naar iedereen.
Weet iemand hoe ik dit kan oplossen?
Alvast vriendelijk bedankt,
Mvg,
Erik