Klein forum met MySQL
Execute de volgende query in je database:
#-->
use database_naam;
#----------------------------
# Table structure for my_forum
#----------------------------
drop table if exists vb_forum;
create table my_forum (
id int(11) not null auto_increment,
name varchar(80) not null,
email varchar(250),
title varchar(55) not null,
msg text not null,
date varchar(250),
rid int(11) not null default '0',
cat int(2) not null,
primary key (id))
type=MyISAM;
#-->
Heb je dat gedaan? Dan ben je bijna klaar. Indien je de tabel een andere naam hebt gegeven dan my_forum moet je in de code nog even de naam van de tabel wijzigen. Via verschillende variabelen kun je dit forum heel makkelijk anders maken. :)
Deze versie is nog zonder admin trouwens. Er word een bijpassende admin gemaakt as soon as posible:) als ik weer eens tijd en zin heb om te progge.. veel plezier met het forum.. :)
PS! Ik gebruik hier de plaatjes arrow.gif en arrow_left.gif! Deze kun je gewoon van deze site rippen of zelf ff wat leuks verzinnen.. :) De directory kan ook worden aangegeven door de dynamic variabelen..
Gesponsorde koppelingen
PHP script bestanden
Er zijn 58 reacties op 'Klein forum met mysql'
Gesponsorde koppelingen
Notice: Undefined variable: id in e:\www\apache\htdocs\forum.php on line 89
dit is het 3e forum dat niet werkt bij mij.
ben ik hiero de enige die dat heeft want ondertussen krijg ik enorm de neiging alles bij mekaar te slaan. en ja, ik heb tabellen en databases aangemaakt !
Eh, dan ook meteen consequent zijn he.... dat zou inhouden dat Windows gebruikers geen site met php zouden bekijken ook.
Wat dus de bruikbaarheid van php meteen een gigantische mep omlaag geeft.
Immers, het merendeel is nog steeds windows.
En trouwens, php op windows hoort niet, maar de php-luitjes hebben wel een windows-versie?
Lijkt mij nogal onlogish... zou hetzelfde zijn als een Mac-only progje maken maar er wel een exe-versie van op de site te zetten, terwijl een Mac niks heeft aan .exe.
Ennuh... bij mij werkt php gewoon prima op windows xp, alleen de wat verouderde scripts willen nog wel eens tegenvallen, of scripts waarvan de maker niet wist waar 'ie mee bezig was.
http://www.linkage.nl/images/redeagle.gif
Wat is dat nu weer ?!
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/html/.../forum.php on line 276
Reageer op dit bericht
| |
Berichten overzicht
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/html/.../forum.php on line 329
-
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/html/.../forum.php on line 350
Er zijn nog geen reacties op dit bericht
Ik krijg de volgende error :/
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Server\htdocs\test\forum\forum.php on line 114
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Server\htdocs\test\forum\forum.php on line 154
op line 105 staat:
$threads = mysql_num_rows($res);
op line 114 staat:
$thispage = mysql_num_rows($res);
op line 154 staat:
while ($row = mysql_fetch_array($res))
Ik weet het nie meer :'(, plz help!!!
Hier wat ik er tot nu toe van heb gebakke..
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
$table = "my_forum";
$set_next = "6";
$set_path = "imgs";
if (!$_GET["cat"])
$cat = 1;
else
$cat = $_GET[cat];
echo "<table width=\"100%\"><tr>";
if (!$_GET["id"] && !$_GET["add"] && !$_POST["add"] && !$_POST["id"])
{
if (!$_GET["p"])
$p = "0";
else
$p = $_GET[p];
echo "<td><a href=$PHP_SELF?add=1>POST EEN ONDERWERP</a></td>";
// check for threads
$sql = "select id from $table where rid = '' and cat = $cat";
$res = mysql_query($sql);
$threads = @mysql_num_rows($res);
// unset vars
$sql = "";
$res = "";
// show topics with replies
$sql = "SELECT * FROM $table WHERE rid = '' AND cat = '$cat' ORDER BY id DESC LIMIT $p,$set_next";
$res = mysql_query($sql);
$thispage = @mysql_num_rows($res);
// show vorige / volgende
if (($threads > $p) && ($thispage >= $set_next))
{
if (!$p)
echo "<a href=\"$PHP_SELF?p=$set_next&cat=$cat\">vorige</a>";
else
{
$next = $p - $set_next;
$p = $p + $set_next;
echo "<a href=\"$PHP_SELF?p=$p&cat=$cat\">vorige</a>";
echo "<a href=\"$PHP_SELF?p=$next&cat=$cat\">volgende</a>";
}
echo "</tr>";
}
elseif ($p)
{
echo "<table width=\"100%\">";
echo "<tr>";
echo "<td align=left>";
$p = $p - $set_next;
echo "<a href=\"$PHP_SELF?p=$p&cat=$cat\">volgende</a>";
echo "</td></tr>";
echo "</table>";
}
// begin table for threads
echo "<table width=\"100%\">";
echo "<tr>";
echo "<td>";
echo "<table>\n";
// loop trough results
while ($row = @mysql_fetch_array($res))
{
$row[onderwerp] = htmlentities($row[onderwerp]);
$row[onderwerp] = nl2br($row[onderwerp]);
$row[name] = htmlentities($row[name]);
$row[name] = nl2br($row[name]);
echo "<tr><td><a href=\"$PHP_SELF?id=$row[id]&p=$p&cat=$cat\">ONDERWERP: $row[onderwerp] $row[date] </a></tr></td>";
$r_sql = "SELECT * FROM $table WHERE rid = $row[id] AND cat = $cat ORDER BY id";
$r_res = mysql_query($r_sql);
if ($r_res)
{
while ($r_row = @mysql_fetch_array($r_res))
{
$r_row[onderwerp] = htmlentities($r_row[onderwerp]);
$r_row[onderwerp] = nl2br($r_row[onderwerp]);
$r_row[name] = htmlentities($r_row[name]);
$r_row[name] = nl2br($r_row[name]);
echo "<tr><td> </td><td>$set_reply<a href=\"$PHP_SELF?id=$r_row[id]&rid=$r_row[rid]&p=$p&cat=$cat\">RE: $r_row[onderwerp]</a>$set_reply2 - $set_name" . "$r_row[name]" . "$set_name2 $set_date" . "$r_row[date]" . "$set_date2</td></tr>\n";
}
}
echo "<tr><td colspan=\"2\"> </td></tr>\n";
}
echo "</table>\n";
echo "</td></tr></table>";
// show vorige / volgende
if (($threads > $p) && ($thispage >= $set_next))
{
echo "<table width=\"100%\">";
echo "<tr>";
echo "<td align=left>";
if (!$p)
echo "<a href=\"$PHP_SELF?p=$set_next&cat=$cat\">vorige</a>";
else
{
echo "</a> <a href=\"$PHP_SELF?p=$p&cat=$cat\">vorige</a>";
echo "<a href=\"$PHP_SELF?p=$next&cat=$_GET[cat]\">volgende</a>";
}
echo "</tr>";
echo "</table><p>";
}
elseif ($p)
{
echo "<table width=\"100%\">";
echo "<tr>";
echo "<td align=left>";
echo "<a href=\"$PHP_SELF?p=$p&cat=$cat\">volgende</a>";
echo "</td></tr>";
echo "</table>";
}
}
//===============================
// show details
//===============================
elseif ($_GET["id"] && !$_GET["add"] && !$_POST["add"])
{
$sql = "select * from $table where id = $id";
$res = mysql_query($sql);
$row = @mysql_fetch_array($res);
$holdid = $row[id];
$row[msg] = htmlentities($row[msg]);
$row[msg] = wordwrap ($row[msg],90,"<br>",1);
$row[msg] = nl2br($row[msg]);
$row[onderwerp] = htmlentities($row[onderwerp]);
$row[onderwerp] = nl2br($row[onderwerp]);
$row[name] = htmlentities($row[name]);
$row[name] = nl2br($row[name]);
if (!$row[email] || !strpos($row[email], "@") && !is_numeric($row[email]))
$author = "$row[name]";
elseif (is_numeric($row[email]))
$author = "<a href=\"$path/profile/?id=$row[email]\">$row[name]</a>";
else
$author = "<a href=\"mailto:$row[email]\">$row[name]</a>";
if ($rid)
$holdit = $rid;
else
$holdit = $id;
echo "<table width=\"100%\">";
echo "<tr>";
echo "<td>";
echo "<table width=\"100%\">";
echo "<tr><td><b>$row[onderwerp] | $author | $row[date]</b></td></tr>";
echo "<tr><td>$row[msg]</td></tr>";
echo "</table>";
echo "</td></tr>";
echo "<tr>";
echo "<td align=left><a href=\"$PHP_SELF?add=1&id=$holdit&p=$p&cat=$cat\">REAGEREN</a></td>";
echo "</tr>";
echo "</table>";
$sql = "";
$res = "";
$row = "";
echo "<table width=\"100%\">";
// get main topic
if ($rid)
$h_sql = "select id,onderwerp,name,date from $table where id = $rid AND cat = '$cat'";
else
$h_sql = "select id,onderwerp,name,date from $table where id = $holdid AND cat = '$cat'";
$h_res = mysql_query($h_sql);
$h_row = @mysql_fetch_array($h_res);
$h_row[onderwerp] = htmlentities($h_row[onderwerp]);
$h_row[onderwerp] = nl2br($h_row[onderwerp]);
$h_row[name] = htmlentities($h_row[name]);
$h_row[name] = nl2br($h_row[name]);
if ($h_row[id] == $holdid)
echo "<tr><td>$set_reply2 - $set_name" . "$h_row[name]" . "$set_name2 $set_date" . "$h_row[date]" . "$set_date2</td></tr>\n";
else
echo "<tr><td>$set_reply<a href=\"$PHP_SELF?id=$h_row[id]&rid=$h_row[rid]&p=$p&cat=$cat\">$h_row[onderwerp]</a>$set_reply2 - $set_name" . "$h_row[name]" . "$set_name2 $set_date" . "$h_row[date]" . "$set_date2</td></tr>\n";
// mysql for reactions
if ($rid)
$sql = "select id,onderwerp,name,date,rid from $table where rid = $rid and cat = $cat ORDER BY id";
else
$sql = "select id,onderwerp,name,date,rid from $table where rid = $id and cat = $cat ORDER BY id";
$res = mysql_query($sql);
if (@mysql_num_rows($res) >= 1)
{
while ($row = @mysql_fetch_array($res))
{
$row[onderwerp] = htmlentities($row[onderwerp]);
$row[onderwerp] = nl2br($row[onderwerp]);
$row[name] = htmlentities($row[name]);
$row[name] = nl2br($row[name]);
// show reactions on it
if ($row[id] == $holdid)
echo "<tr><td>$set_reply2 - $set_name" . "$row[name]" . "$set_name2 $set_date" . "$row[date]" . "$set_date2</td></tr>\n";
else
echo "<tr><td>$set_reply<a href=\"$PHP_SELF?id=$row[id]&rid=$row[rid]&p=$p&cat=$cat\">$row[onderwerp]</a>$set_reply2 - $set_name" . "$row[name]" . "$set_name2 $set_date" . "$row[date]" . "$set_date2</td></tr>\n";
}
}
else
{
echo "<tr><td> </td></tr>";
echo "<tr><td><b><i>GEEN REACTIES</a></td></tr>\n";
}
echo "</table>";
echo "<p> </p>";
if ($rid)
$holdit = $rid;
else
$holdit = $id;
echo "<table width=\"100%\">";
echo "<tr>";
echo "<td align=left><a href=\"$PHP_SELF?p=$p&cat=$cat\">Vorige pagina</a></td>";
echo "</tr>";
echo "</table>";
}
//===============================
// add thread or reply
//===============================
elseif ($_GET["add"] || $_POST["add"])
{
if ($_POST["submit"] && ($_POST["name"] && $_POST["onderwerp"] && $_POST["msg"]))
{
// set date
$date = date("d.m.Y [H:i]");
$sql = "INSERT INTO $table (id, name, email, onderwerp, msg, date, rid, cat) VALUES ('', '$_POST[name]', '$POST[email]', '$_POST[onderwerp]', '$_POST[msg]', '$date', '$rid', '$cat')";
$res = mysql_query($sql);
if ($res)
{
echo "<table width=\"100%\">";
echo "<tr>";
echo "<td>";
echo "TNX voor je bijdragen <b>$_POST[name]</b>!!<p>";
if ($rid)
echo "<a href=$PHP_SELF?id=$rid&p=$p&cat=$cat>TERUG NAAR BERICHT</a>";
else
echo "<a href=$PHP_SELF?p=$p&cat=$cat>TERUG NAAR DE BERICHTEN</a>";
echo "</td>";
echo "</tr>";
echo "</table><p>";
}
else
{
echo "FOUTJE BEDANKT PROBEER HET NOG MAAR EEN KEER..";
}
}
else
{
if ($_GET["id"] || $_POST["id"])
{
if ($_GET["id"])
$sql = "SELECT onderwerp FROM $table WHERE id = $_GET[id]";
else
$sql = "SELECT onderwerp FROM $table WHERE id = $_POST[id]";
$res = mysql_query($sql);
if (substr(mysql_result($res, 0), 0, 3) != "BLA:")
$onderwerp = "BLA: " . mysql_result($res, 0);
else
$onderwerp = mysql_result($res, 0);
}
if ($_POST["submit"] && (!$_POST["name"] || !$_POST["onderwerp"] || !$_POST["msg"]))
{
$err = "<b>JE VERGEET WAT... IRRITANT haha ...</b><p>";
}
echo "<table width=\"100%\">";
echo "<tr>";
echo "<td align=left>";
if ($id)
echo "<a href=\"$PHP_SELF?id=$id&cat=$cat&p=$p\">TERUG NAAR BERICHT</a></a>";
else
echo "<a href=\"$PHP_SELF?&cat=$cat&p=$p\">TERUG NAAR DE BERICHTEN</a></a>";
echo "</td>";
echo "</tr>";
echo "</table><p>";
// begin table with form
echo "<table width=\"100%\">";
echo "<tr>";
echo "<td>";
echo "<p> </p>";
echo "<p> </p>";
echo "<center><table>\n";
echo "<tr><td>$err</td></tr>";
//echo "<tr><td>";
echo "<form method=post action=$PHP_SELF>";
echo "<input type=hidden name=add value=1>";
if ($_GET["id"] || $_POST["id"])
{
if ($_GET["id"])
echo "<input type=hidden name=rid value=$_GET[id]>";
else
echo "<input type=hidden name=rid value=$_POST[id]>";
}
else
{
if ($_GET["rid"])
echo "<input type=hidden name=rid value=$_GET[rid]>";
else
echo "<input type=hidden name=rid value=$_POST[rid]>";
}
if ($_GET["p"])
echo "<input type=hidden name=p value=$_GET[p]>";
else
echo "<input type=hidden name=p value=$_POST[p]>";
if ($_GET["cat"])
echo "<input type=hidden name=cat value=$_GET[cat]>";
else
echo "<input type=hidden name=cat value=$_POST[cat]>";
echo "<center><b><i>NAAM:</i></b><br></center>";
echo "<center><input size=\"50\"type=text name=name value=\"$_POST[name]\" $disabled></center>";
if (!$disabled)
{
echo "<center><b><i>EMAIL</i></b><br></center>";
echo "<center><input size=\"50\" type=text name=email value=\"$_POST[email]\"></center>";
}
echo "<center><b><i>ONDERWERP</i></b><br></center>";
if ($title)
echo "<center><input size=\"50\" type=text name=onderwerp value=\"$onderwerp\"></center>";
else
{
if ($_GET["onderwerp"])
echo "<center><input size=\"50\" type=text name=onderwerp value=\"$_GET[onderwerp]\"></center>";
else
echo "<center><input size=\"50\" type=text name=onderwerp value=\"$_POST[onderwerp]\"></center>";
}
echo "<center><b><i>BERICHT</i></b><br></center>";
echo "<center><textarea name=msg cols=35 rows=6>$_POST[msg]</textarea></center>";
echo "<center><input type=submit name=submit value=\"POST\"><p></center>";
echo "</form>";
echo "</table></center>";
echo "<p> </p>";
echo "</td>";
echo "</tr>";
echo "</table><P>";
}
}
echo "</td></tr></table>";
?>
In het geval van ja:
Ergens zit een knopje (ik geloof in de linker balk) waarmee je een invoervenster voorgeschoteld krijgt waar je vervolgens je query in kan plakken, en dan kan uitvoeren.
(Je kan hem ook gewoon in een mysql_query() stoppen, maar phpMyAdmin geeft altijd wel een mooi overzicht van de resultaten.)
Bedankt!
Ik ken al een beetje mysql alleen ben hierop vastgelopen, en ben nu 2 weken aan het zoeken :S.
Ik heb weleens gehoord van phpmyadmin, moet ik daarmee werken?
Alvast heel erg bedankt voor degene die me kan helpen!!
@Joris: Ja, om de tabellen aan te maken heb je phpmyadmin nodig. Ga binnen phpmyadmin naar SQL en plak in dat veld de CREATE TABLE bovengenoemde delen.
Maak in het script een goede verbinding naar de database en je forum moet draaien
---------------------------------------
Waar download ik phpMyAdmin en hoe installeer ik phpMyAdmin?
U kunt phpMyAdmin downloaden van http://www.phpmyadmin.net/
Voor de mensen die niet weten wat zip en rar betekend kunnen de onderstaande link klikken om phpMyAdmin te downloaden.
http://www.phpmyadmin.net/index.php?dl=3
Ik ga u nu uitleggen hoe u de basis van phpMyAdmin installeert.
U pakt het .zip bestand van phpMyAdmin uit met bijvoorbeeld Winzip of Winrar.
U hernoemt de map phpMyAdmin-xxxxx (de x is uw versie nummer van phpMyAdmin) naar phpmyadmin.
U opent de map phpmyadmin.
U opent het bestand config.php met EditPlus of uw favoriete PHP editor.
Bij de var $cfg['PmaAbsoluteUri'] = ''; vult u uw adres in waar u de phpmyadmin plaatst.
Dus bijvoorbeeld $cfg['PmaAbsoluteUri'] = ''http://www.uwsite.nl/phpmyadmin/;
U veranderd de eerste var met deze naam $cfg['Servers'][$i]['auth_type'] = 'config'; naar:
$cfg['Servers'][$i]['auth_type'] = 'cookie';
U slaat het bestand “config.inc.php” op en u sluit uw editor.
U upload de phpmyadmin map naar uw website map toe op uw hosting provider server.
U gaat naar http://www.uwsite.nl/phpmyadmin/ en als alles goed is verlopen doet phpMyAdmin het!
Veel plezier met phpMyAdmin
------------------------------------
heb ik een verkeerde link naar de download? alles werkt tot ik het bestand config.php moet openen; maar die bestaat niet. :S
help help help
Alvast heel erg bedankt!!
Verder zijn er nog vele andere tools om MySQL-databases te beheren, bv. SQL Manager 2005 for MySQL. De Lite-versie is gratis te downloaden en te gebruiken. Dit werkt 100x beter dan PMA.
moet ik nog iets naar de server zelf uploaden?
sorry voor al die vragen, en t zal wel heel makkelijk zijn, alleen van de installatie snap ik er de ballen van en dat is nergens te vinden. :S
nogmaals bedankt!!
#-->
use database_naam;
#----------------------------
# Table structure for my_forum
#----------------------------
drop table if exists vb_forum;
create table my_forum (
id int(11) not null auto_increment,
name varchar(80) not null,
email varchar(250),
title varchar(55) not null,
msg text not null,
date varchar(250),
rid int(11) not null default '0',
cat int(2) not null,
primary key (id))
type=MyISAM;
plz help hoe kan ik dit doen bij freehostia??
ik ben namelijk beginner en wil een forum
Je bericht kon niet worden toegevoegd, probeer het opnieuw.
http://murtazay.mu.funpic.de/Forum.php?add=1
en kunnen jullie helpen hoe je die lettertype in ^url kleiner kunt maken?
Groetjes Corina
Hieronder mijn code:
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
// ===========================
// forum in shape of guestbook
// ===========================
// variables
// set table of database
$table = "my_forum";
// set webmaster's e-mail address
$set_email = "info@******.nl";
// set name of forum
$set_forum = "reactie forum";
// set color for name of forum
$set_head = "<font color=\"#006600\">";
$set_head2 = "</font>";
// main topic (leave blanc for no styles)
$set_main = "<b>";
$set_main2 = "</b>";
// replies (leave blanc for no styles)
$set_reply = "";
$set_reply2 = "";
// decide date style (leave blanc for no styles)
$set_date = "<span class=\"small\"><i>";
$set_date2 = "</i></span>";
// decide name style (leave blanc for no style)
$set_name = "<font color=\"blue\">";
$set_name2 = "</font>";
// set bgcolor of active title bar
$set_title = "#cccfff";
// set bgcolor of inactive title bar
$set_titlebar = "#cccccc";
// give border color for bottom volgende/volgende page
$set_bcolor = "#000000";
// show (define here) threads per page
$set_next = "15";
// define image path ZONDER SLASH!!!!!
$set_path = "imgs";
// make database connection
$host = "localhost";
$user = "****";
$pass = "****";
$dbdb = "****";
// check if database connection's valid
if (!mysql_select_db($dbdb, mysql_connect($host, $user, $pass)))
{
echo "Er kon geen connectie gemaakt worden met de database.<P>";
echo "Probeer het opnieuw, of waarschuw de webmaster op $set_email.<p>";
exit();
}
// echo name of forum
echo "<h2>$set_head" . "$set_forum" . "$set_head2</h2>";
if (!$_GET["cat"])
$cat = 1;
else
$cat = $_GET[cat];
echo "<table width=\"500\" border=\"0\" cellspacing=\"10\" cellpadding=\"0\">";
echo "<tr valign=\"top\">";
echo "<td width=\"10%\">";
//===============================
// show overview
//===============================
if (!$_GET["id"] && !$_GET["add"] && !$_POST["add"] && !$_POST["id"])
{
// set threads
if (!$_GET["p"])
$p = "0";
else
$p = $_GET[p];
echo "<p><a href=" . $_SERVER['PHP_SELF'] . "?add=1>Voeg een nieuw bericht toe</a></p>";
// check for threads
$sql = "select id from $table where rid = '' and cat = $cat";
$res = mysql_query($sql);
$threads = mysql_num_rows($res);
// unset vars
$sql = "";
$res = "";
// show topics with replies
$sql = "SELECT * FROM $table WHERE rid = '' AND cat = '$cat' ORDER BY id DESC LIMIT $p,$set_next";
$res = mysql_query($sql);
$thispage = mysql_num_rows($res);
// show vorige / volgende
if (($threads > $p) && ($thispage >= $set_next))
{
echo "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">";
echo "<tr>";
echo "<td align=left>";
if (!$p)
echo "<a href=" . $_SERVER['PHP_SELF'] . "?p=$set_next&cat=$cat><img src=$set_path/arrow_left.gif border=0></a> <a href=\"" . $_SERVER['PHP_SELF'] . "?p=$set_next&cat=$cat\">vorige</a>";
else
{
$next = $p - $set_next;
$p = $p + $set_next;
echo "<a href=" . $_SERVER['PHP_SELF'] . "?p=$p&cat=$cat><img src=$set_path/arrow_left.gif border=0></a> <a href=\"" . $_SERVER['PHP_SELF'] . "?p=$p&cat=$cat\">vorige</a> | ";
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?p=$next&cat=$cat\">volgende</a> <a href=" . $_SERVER['PHP_SELF'] . "?p=$next&cat=$cat><img src=$set_path/arrow.gif border=0></a>";
}
echo "</tr>";
echo "</table><p>";
}
elseif ($p)
{
echo "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">";
echo "<tr>";
echo "<td align=left>";
$p = $p - $set_next;
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?p=$p&cat=$cat\">volgende</a> <a href=" . $_SERVER['PHP_SELF'] . "?p=$p&cat=$cat><img src=$set_path/arrow.gif border=0></a>";
echo "</td></tr>";
echo "</table>";
}
// begin table for threads
echo "<table width=\"100%\" border=\"1\" cellpadding=\"8\" cellspacing=\"0\">";
echo "<tr>";
echo "<td>";
echo "<table border=0 cellspacing=0 cellpadding=0>\n";
// loop trough results
while ($row = mysql_fetch_array($res))
{
$row[title] = htmlentities($row[title]);
$row[title] = nl2br($row[title]);
$row[name] = htmlentities($row[name]);
$row[name] = nl2br($row[name]);
echo "<tr><td colspan=\"2\">$set_main<a href=\"" . $_SERVER['PHP_SELF'] . "?id=$row[id]&p=$p&cat=$cat\">$row[title]</a>$set_main2 - $set_name" . "$row[name]" . "$set_name2 $set_date" . "$row[date]" . "$set_date2</td></tr>\n";
$r_sql = "SELECT * FROM $table WHERE rid = $row[id] AND cat = $cat ORDER BY id";
$r_res = mysql_query($r_sql);
if ($r_res)
{
while ($r_row = mysql_fetch_array($r_res))
{
$r_row[title] = htmlentities($r_row[title]);
$r_row[title] = nl2br($r_row[title]);
$r_row[name] = htmlentities($r_row[name]);
$r_row[name] = nl2br($r_row[name]);
echo "<tr><td> </td><td>$set_reply<a href=\"" . $_SERVER['PHP_SELF'] . "?id=$r_row[id]&rid=$r_row[rid]&p=$p&cat=$cat\">$r_row[title]</a>$set_reply2 - $set_name" . "$r_row[name]" . "$set_name2 $set_date" . "$r_row[date]" . "$set_date2</td></tr>\n";
}
}
echo "<tr><td colspan=\"2\"> </td></tr>\n";
}
echo "</table>\n";
echo "</td></tr></table>";
// show vorige / volgende
if (($threads > $p) && ($thispage >= $set_next))
{
echo "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">";
echo "<tr>";
echo "<td align=left>";
if (!$p)
echo "<a href=" . $_SERVER['PHP_SELF'] . "?p=$set_next&cat=$cat><img src=$set_path/arrow_left.gif border=0></a> <a href=\"" . $_SERVER['PHP_SELF'] . "?p=$set_next&cat=$cat\">vorige</a>";
else
{
echo "<a href=" . $_SERVER['PHP_SELF'] . "?p=$p&cat=$_GET[cat]><img src=$set_path/arrow_left.gif border=0></a> <a href=\"" . $_SERVER['PHP_SELF'] . "?p=$p&cat=$cat\">vorige</a> | ";
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?p=$next&cat=$_GET[cat]\">volgende</a> <a href=" . $_SERVER['PHP_SELF'] . "?p=$next&cat=$_GET[cat]><img src=$set_path/arrow.gif border=0></a>";
}
echo "</tr>";
echo "</table><p>";
}
elseif ($p)
{
echo "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">";
echo "<tr>";
echo "<td align=left>";
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?p=$p&cat=$cat\">volgende</a> <a href=" . $_SERVER['PHP_SELF'] . "?p=$p&cat=$cat><img src=$set_path/arrow.gif border=0></a>";
echo "</td></tr>";
echo "</table>";
}
}
//===============================
// show details
//===============================
elseif ($_GET["id"] && !$_GET["add"] && !$_POST["add"])
{
$sql = "select * from $table where id = $id";
$res = mysql_query($sql);
$row = mysql_fetch_array($res);
$holdid = $row[id];
$row[msg] = htmlentities($row[msg]);
$row[msg] = nl2br($row[msg]);
$row[title] = htmlentities($row[title]);
$row[title] = nl2br($row[title]);
$row[name] = htmlentities($row[name]);
$row[name] = nl2br($row[name]);
if (!$row[email] || !strpos($row[email], "@") && !is_numeric($row[email]))
$author = "$row[name]";
elseif (is_numeric($row[email]))
$author = "<a href=\"$path/profile/?id=$row[email]\">$row[name]</a>";
else
$author = "<a href=\"mailto:$row[email]\">$row[name]</a>";
if ($rid)
$holdit = $rid;
else
$holdit = $id;
echo "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">";
echo "<tr>";
echo "<td align=left><a href=" . $_SERVER['PHP_SELF'] . "?add=1&id=$holdit&p=$p&cat=$cat><img src=$set_path/arrow.gif border=0></a> <a href=\"" . $_SERVER['PHP_SELF'] . "?add=1&id=$holdit&p=$p&cat=$cat\">Reageer op dit bericht</a></td>";
echo "</tr>";
echo "</table><p>";
echo "<table width=\"100%\" border=\"1\" cellpadding=\"8\" cellspacing=\"0\">";
echo "<tr>";
echo "<td>";
echo "<table border=0 cellspacing=0 cellpadding=0 width=\"100%\">";
echo "<tr><td height=\"20\" bgcolor=\"$set_title\"><b>$row[title] | $author | $row[date]</b></td></tr>";
echo "<tr><td>$row[msg]</td></tr>";
echo "</table><p>";
echo "</td></tr></table><p>";
$sql = "";
$res = "";
$row = "";
echo "<table border=0 cellspacing=0 cellpadding=0 width=\"100%\">";
echo "<tr><td height=\"20\" bgcolor=\"$set_titlebar\">Berichten overzicht</td></tr>";
// get main topic
if ($rid)
$h_sql = "select id,title,name,date from $table where id = $rid AND cat = '$cat'";
else
$h_sql = "select id,title,name,date from $table where id = $holdid AND cat = '$cat'";
$h_res = mysql_query($h_sql);
$h_row = mysql_fetch_array($h_res);
$h_row[title] = htmlentities($h_row[title]);
$h_row[title] = nl2br($h_row[title]);
$h_row[name] = htmlentities($h_row[name]);
$h_row[name] = nl2br($h_row[name]);
if ($h_row[id] == $holdid)
echo "<tr><td><img src=\"$set_path/arrow.gif\"> $set_reply<a href=\"" . $_SERVER['PHP_SELF'] . "?id=$h_row[id]&rid=$h_row[rid]&p=$p&cat=$cat\">$h_row[title]</a>$set_reply2 - $set_name" . "$h_row[name]" . "$set_name2 $set_date" . "$h_row[date]" . "$set_date2</td></tr>\n";
else
echo "<tr><td>$set_reply<a href=\"" . $_SERVER['PHP_SELF'] . "?id=$h_row[id]&rid=$h_row[rid]&p=$p&cat=$cat\">$h_row[title]</a>$set_reply2 - $set_name" . "$h_row[name]" . "$set_name2 $set_date" . "$h_row[date]" . "$set_date2</td></tr>\n";
// mysql for reactions
if ($rid)
$sql = "select id,title,name,date,rid from $table where rid = $rid and cat = $cat ORDER BY id";
else
$sql = "select id,title,name,date,rid from $table where rid = $id and cat = $cat ORDER BY id";
$res = mysql_query($sql);
if (mysql_num_rows($res) >= 1)
{
while ($row = mysql_fetch_array($res))
{
$row[title] = htmlentities($row[title]);
$row[title] = nl2br($row[title]);
$row[name] = htmlentities($row[name]);
$row[name] = nl2br($row[name]);
// show reactions on it
if ($row[id] == $holdid)
echo "<tr><td><img src=\"$set_path/arrow.gif\"> $set_reply<a href=\"" . $_SERVER['PHP_SELF'] . "?id=$row[id]&rid=$row[rid]&p=$p&cat=$cat\">$row[title]</a>$set_reply2 - $set_name" . "$row[name]" . "$set_name2 $set_date" . "$row[date]" . "$set_date2</td></tr>\n";
else
echo "<tr><td>$set_reply<a href=\"" . $_SERVER['PHP_SELF'] . "?id=$row[id]&rid=$row[rid]&p=$p&cat=$cat\">$row[title]</a>$set_reply2 - $set_name" . "$row[name]" . "$set_name2 $set_date" . "$row[date]" . "$set_date2</td></tr>\n";
}
}
else
{
echo "<tr><td> </td></tr>";
echo "<tr><td><b><i>Er zijn nog geen reacties op dit bericht</a></td></tr>\n";
}
echo "</table>";
echo "<p> </p>";
if ($rid)
$holdit = $rid;
else
$holdit = $id;
echo "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">";
echo "<tr>";
echo "<td align=left><a href=" . $_SERVER['PHP_SELF'] . "?p=$p&cat=$cat><img src=$set_path/arrow_left.gif border=0></a> <a href=\"" . $_SERVER['PHP_SELF'] . "?p=$p&cat=$cat\">Vorige pagina</a> <a href=" . $_SERVER['PHP_SELF'] . "?add=1&id=$holdit&p=$p&cat=$cat><img src=$set_path/arrow.gif border=0></a> <a href=\"" . $_SERVER['PHP_SELF'] . "?add=1&id=$holdit&p=$p&cat=$cat\">Reageer op dit bericht</a></td>";
echo "</tr>";
echo "</table><p>";
}
//===============================
// add thread or reply
//===============================
elseif ($_GET["add"] || $_POST["add"])
{
if ($_POST["submit"] && ($_POST["name"] && $_POST["title"] && $_POST["msg"]))
{
// set date
$date = date("d.m.Y [H:i]");
$sql = "INSERT INTO $table (id, name, email, title, msg, date, rid, cat) VALUES ('', '$_POST[name]', '$POST[email]', '$_POST[title]', '$_POST[msg]', '$date', '$rid', '$cat')";
$res = mysql_query($sql);
if ($res)
{
echo "<table width=\"100%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\">";
echo "<tr>";
echo "<td>";
echo "Bedankt voor je bericht <b>$_POST[name]</b>!!<p>";
if ($rid)
echo "<a href=" . $_SERVER['PHP_SELF'] . "?p=$p&id=$rid&cat=$cat><img src=$set_path/arrow_left.gif border=0></a> <a href=" . $_SERVER['PHP_SELF'] . "?id=$rid&p=$p&cat=$cat>Ga terug naar het bericht</a>";
else
echo "<a href=" . $_SERVER['PHP_SELF'] . "?p=$p&cat=$cat><img src=$set_path/arrow_left.gif border=0></a> <a href=" . $_SERVER['PHP_SELF'] . "?p=$p&cat=$cat>Ga terug naar de berichten</a>";
echo "</td>";
echo "</tr>";
echo "</table><p>";
}
else
{
echo "Je bericht kon niet worden toegevoegd, probeer het opnieuw.";
}
}
else
{
if ($_GET["id"] || $_POST["id"])
{
if ($_GET["id"])
$sql = "SELECT title FROM $table WHERE id = $_GET[id]";
else
$sql = "SELECT title FROM $table WHERE id = $_POST[id]";
$res = mysql_query($sql);
if (substr(mysql_result($res, 0), 0, 3) != "Re:")
$title = "Re: " . mysql_result($res, 0);
else
$title = mysql_result($res, 0);
}
if ($_POST["submit"] && (!$_POST["name"] || !$_POST["title"] || !$_POST["msg"]))
{
$err = "<b>Je bent vergeten enkele velden in te vullen</b><p>";
}
echo "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">";
echo "<tr>";
echo "<td align=left>";
if ($id)
echo "<a href=" . $_SERVER['PHP_SELF'] . "?id=$id&cat=$cat&p=$p><img src=$set_path/arrow_left.gif border=0></a> <a href=\"" . $_SERVER['PHP_SELF'] . "?id=$id&cat=$cat&p=$p\">terug naar het bericht</a></a>";
else
echo "<a href=" . $_SERVER['PHP_SELF'] . "&cat=$cat&p=$p><img src=$set_path/arrow_left.gif border=0></a> <a href=\"" . $_SERVER['PHP_SELF'] . "?&cat=$cat&p=$p\">terug naar de berichten</a></a>";
echo "</td>";
echo "</tr>";
echo "</table><p>";
// begin table with form
echo "<table width=\"100%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\">";
echo "<tr>";
echo "<td>";
echo "<p> </p>";
echo "<p> </p>";
echo "<table border=0 cellspacing=0 cellpadding=0 border=0>\n";
echo "<tr><td>$err</td></tr>";
echo "<tr><td>";
echo "<form method=post action=" . $_SERVER['PHP_SELF'] . ">";
echo "<input type=hidden name=add value=1>";
if ($_GET["id"] || $_POST["id"])
{
if ($_GET["id"])
echo "<input type=hidden name=rid value=$_GET[id]>";
else
echo "<input type=hidden name=rid value=$_POST[id]>";
}
else
{
if ($_GET["rid"])
echo "<input type=hidden name=rid value=$_GET[rid]>";
else
echo "<input type=hidden name=rid value=$_POST[rid]>";
}
if ($_GET["p"])
echo "<input type=hidden name=p value=$_GET[p]>";
else
echo "<input type=hidden name=p value=$_POST[p]>";
if ($_GET["cat"])
echo "<input type=hidden name=cat value=$_GET[cat]>";
else
echo "<input type=hidden name=cat value=$_POST[cat]>";
echo "<b>Naam*:</b><br>";
echo "<input type=text name=name value=\"$_POST[name]\" $disabled><p>";
if (!$disabled)
{
echo "<b>Email</b><br>";
echo "<input type=text name=email value=\"$_POST[email]\"><p>";
}
echo "<b>Titel*</b><br>";
if ($title)
echo "<input type=text name=title value=\"$title\"><p>";
else
{
if ($_GET["title"])
echo "<input type=text name=title value=\"$_GET[title]\"><p>";
else
echo "<input type=text name=title value=\"$_POST[title]\"><p>";
}
echo "<b>Bericht*</b><br>";
echo "<textarea name=msg cols=55 rows=6>$_POST[msg]</textarea><p>";
echo "<input type=submit name=submit value=\"Plaats bericht!\"><p>";
echo "</form>";
echo "</td></tr>";
echo "</table>";
echo "<p> </p>";
echo "</td>";
echo "</tr>";
echo "</table><P>";
}
}
echo "</td></tr></table>";
?>
2
3
4
5
6
7
8
9
10
11
12
13
14
$sql = 'CREATE TABLE `my_forum` ('
. ' `id` INT(11) NOT NULL AUTO_INCREMENT, '
. ' `name` VARCHAR(80) NOT NULL, '
. ' `email` VARCHAR(250) NOT NULL, '
. ' `title` VARCHAR(55) NOT NULL, '
. ' `msg` TEXT NOT NULL, '
. ' `date` VARCHAR(250) NOT NULL, '
. ' `rid` INT(11) NOT NULL DEFAULT \'0\', '
. ' `cat` INT(2) NOT NULL'
. ' PRIMARY KEY (`id`))'
. ' ENGINE = myisam;';
?>
Dit moet je wel invullen he.
// make database connection
$host = "localhost"; // locatie van je database
$user = "****"; // gebruikersnaam van je database
$pass = "****"; // wachtwoord van je database
$dbdb = "****"; // naam van je database
Houd er wel rekening mee dat dit script 6 jaar oud is en dus niet is gemaakt voor de huidige php versies!
Om te reageren heb je een account nodig en je moet ingelogd zijn.
Inhoudsopgave
Labels
- Geen tags toegevoegd.
PHP hulp
0 seconden vanaf nu