Forum probleem
Voorbeeld kan je hier bekijken:
http://www.kristofdebleu.net/qparty/crew/login.php
Inloggen met: demo - demo
index.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
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
<?
$page_nr = $_REQUEST['page_nr'] && is_numeric($_REQUEST['page_nr']) ? $_REQUEST['page_nr'] : 0;
$x = $page_nr * $messages_per_page;
$sql = "SELECT * FROM forum WHERE replyop = 0 ORDER BY date_submit DESC LIMIT ".$x.", ".$messages_per_page;
$res = mysql_query($sql) or die(mysql_error());
$que1 = "SELECT * FROM forum WHERE replyop = 0";
$out1 = mysql_query($que1) or die(mysql_error());
$num = mysql_num_rows($out1);
?>
<table width="580" border=0 cellspacing=0 cellpadding=0>
<tr>
<td height="20" align="right">
<a href="<?=sprintf($url, 'message')?>">Voeg een bericht toe</a> |
<?
if ($page_nr > 0) {
echo "<a href=\"".sprintf($url, 'index')."&page_nr=".($page_nr - 1)."\">Volgende ".$messages_per_page." berichten</a> | ";
}
else {
echo "Volgende ".$messages_per_page." berichten | ";
}
if ($num > $messages_per_page + $messages_per_page * $page_nr) {
echo "<a href=\"".sprintf($url, 'index')."&page_nr=" . ($page_nr + 1) . "\">Vorige ".$messages_per_page." berichten</a>";
}
else {
echo "Vorige ".$messages_per_page." berichten";
}
?>
</td>
</tr>
</table>
<table width="580" border=0 cellspacing=0 cellpadding=1>
<tr><td class="MainTD">
<table width="100%" border=0 cellspacing=0 cellpadding=3>
<tr>
<td height="20" class="HeaderText">Onderwerp:</td>
<td height="20" class="HeaderText">Door:</td>
<td height="20" class="HeaderText">Antwoorden:</td>
</tr>
<?
while($row = mysql_fetch_object($res)){
?>
<tr>
<td width="65%" height="20" nowrap><a href="<?=sprintf($url, 'read')?>&id=<?=$row->id?>"> <?=(strlen($row->onderwerp) > $max_length) ? substr(htmlspecialchars($row->onderwerp),0,$max_length)."..." : htmlspecialchars($row->onderwerp)?></td>
<td width="30%" height="20" nowrap><?=(strlen($row->naam) > $max_length) ? substr(htmlspecialchars($row->naam),0,$max_length)."..." : htmlspecialchars($row->naam)?></td>
<td height="20" nowrap><?=$row->replys?></td>
</tr>
<?
}
?>
</table>
</td>
</tr>
</table>
<table width="580" border=0 cellspacing=0 cellpadding=0>
<tr>
<td height="20" align="right">
<a href="<?=sprintf($url, 'message')?>">Voeg een bericht toe</a>
</td>
</tr>
</table>
$page_nr = $_REQUEST['page_nr'] && is_numeric($_REQUEST['page_nr']) ? $_REQUEST['page_nr'] : 0;
$x = $page_nr * $messages_per_page;
$sql = "SELECT * FROM forum WHERE replyop = 0 ORDER BY date_submit DESC LIMIT ".$x.", ".$messages_per_page;
$res = mysql_query($sql) or die(mysql_error());
$que1 = "SELECT * FROM forum WHERE replyop = 0";
$out1 = mysql_query($que1) or die(mysql_error());
$num = mysql_num_rows($out1);
?>
<table width="580" border=0 cellspacing=0 cellpadding=0>
<tr>
<td height="20" align="right">
<a href="<?=sprintf($url, 'message')?>">Voeg een bericht toe</a> |
<?
if ($page_nr > 0) {
echo "<a href=\"".sprintf($url, 'index')."&page_nr=".($page_nr - 1)."\">Volgende ".$messages_per_page." berichten</a> | ";
}
else {
echo "Volgende ".$messages_per_page." berichten | ";
}
if ($num > $messages_per_page + $messages_per_page * $page_nr) {
echo "<a href=\"".sprintf($url, 'index')."&page_nr=" . ($page_nr + 1) . "\">Vorige ".$messages_per_page." berichten</a>";
}
else {
echo "Vorige ".$messages_per_page." berichten";
}
?>
</td>
</tr>
</table>
<table width="580" border=0 cellspacing=0 cellpadding=1>
<tr><td class="MainTD">
<table width="100%" border=0 cellspacing=0 cellpadding=3>
<tr>
<td height="20" class="HeaderText">Onderwerp:</td>
<td height="20" class="HeaderText">Door:</td>
<td height="20" class="HeaderText">Antwoorden:</td>
</tr>
<?
while($row = mysql_fetch_object($res)){
?>
<tr>
<td width="65%" height="20" nowrap><a href="<?=sprintf($url, 'read')?>&id=<?=$row->id?>"> <?=(strlen($row->onderwerp) > $max_length) ? substr(htmlspecialchars($row->onderwerp),0,$max_length)."..." : htmlspecialchars($row->onderwerp)?></td>
<td width="30%" height="20" nowrap><?=(strlen($row->naam) > $max_length) ? substr(htmlspecialchars($row->naam),0,$max_length)."..." : htmlspecialchars($row->naam)?></td>
<td height="20" nowrap><?=$row->replys?></td>
</tr>
<?
}
?>
</table>
</td>
</tr>
</table>
<table width="580" border=0 cellspacing=0 cellpadding=0>
<tr>
<td height="20" align="right">
<a href="<?=sprintf($url, 'message')?>">Voeg een bericht toe</a>
</td>
</tr>
</table>
message.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
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
<?
if($_REQUEST['id']){
$sql = "SELECT replyop FROM forum WHERE id = '".mysql_escape_string($_REQUEST['reply'])."'";
$reply = mysql_fetch_array(mysql_query($sql));
if($reply['replyop'] > 0) {
header("Location: ".sprintf($url, 'index'));
}
}
$ok = 0;
if($_POST["submit"]) {
$ok = 1;
if(empty($_POST['onderwerp']))
$err[] = "You've forgotten your subject!";
if(empty($_POST['naam']))
$err[] = "You've forgotten your name!";
if(empty($_POST['bericht']))
$err[] = "You've forgotten your message!";
for($i=0;$i<sizeof($bad_words);$i++)
if(ereg($bad_words[$i], $_POST['naam']) || ereg($bad_words[$i], $_POST['onderwerp']) || ereg($bad_words[$i], $_POST['bericht']))
$err[] = "We like to keep our forum desent. Please use some normal language!";
if(sizeof($err) > 0) {
?>
<table width="580" border=0 cellspacing=0 cellpadding=0>
<tr><td class="MainTD">
<table width="100%" border=0 cellspacing=1 cellpadding=3>
<tr>
<td class="HeaderText">Error:</td>
</tr>
<tr>
<td valign="top" align="left" class="NormalText">
<form method="POST" action="<?=sprintf($url, 'message')?>">
<input type="hidden" name="onderwerp" value="<?=$_POST['onderwerp']?>">
<input type="hidden" name="naam" value="<?=$_POST['naam']?>">
<input type="hidden" name="bericht" value="<?=$_POST['bericht']?>">
<input type="hidden" name="reply" value="<?=$_POST['reply']?>">
Something went wrong. Please take attention to the errors below.<br><br>
<?
for($i=0;$i<=sizeof($err);$i++)
echo "\n\t<font class=\"Error\">".$err[$i]."</font><br>";
?>
<input type="submit" value="Back">
</form>
</td>
</tr>
</table>
</td></tr>
</table>
<?
} else {
$sql = "INSERT INTO forum (id, onderwerp, naam, bericht, date_submit, replyop) VALUES ('', '".mysql_escape_string($_POST['onderwerp'])."', '".mysql_escape_string($_POST['naam'])."', '".mysql_escape_string($_POST['bericht'])."', NOW(), '".$reply."')";
mysql_query($sql) or die("<h1>Something went wrong</h1><hr>".mysql_error());
if($_POST['reply'] <> 0) {
$sql = "UPDATE forum SET replys = replys + 1 WHERE id = '".mysql_escape_string($_POST['reply'])."'";
mysql_query($sql) or die("<h1>Something went wrong</h1><hr>".mysql_error());
}
if(!$_POST['reply'])
header("Location: ".sprintf($url, 'index'));
else
header("Location: ".sprintf($url, 'read')."&id=".$_POST['reply']);
}
} else {
?>
<table width="580" border=0 cellspacing=0 cellpadding=0>
<tr><td class="MainTD">
<table width="100%" border=0 cellspacing=1 cellpadding=3>
<tr>
<td class="HeaderText"><br></td>
</tr>
<tr>
<td valign="top" align="left" class="NormalText">
<form name="postform" onsubmit="SubmitOnce(this);" method="POST" action="<?=sprintf($url, 'message')?>">
Uw naam:<br>
<input type="text" name="naam" value="<?=$_POST['naam']?>"><br>
Onderwerp:<br>
<input type="text" name="onderwerp" value="<?=$_POST['onderwerp']?>"><br>
Uw bericht:<br>
<textarea name="bericht" rows="8" cols="40"><?=$_POST['bericht']?></textarea><br>
<input type="hidden" name="reply" value="<?=$_REQUEST['reply']?>">
<input type="hidden" name="submit" value="true">
<input type="submit" value="Toevoegen">
<input type="reset" value="Leegmaken">
</form>
</td>
</tr>
</table>
</td></tr>
</table>
<?
}
?>
if($_REQUEST['id']){
$sql = "SELECT replyop FROM forum WHERE id = '".mysql_escape_string($_REQUEST['reply'])."'";
$reply = mysql_fetch_array(mysql_query($sql));
if($reply['replyop'] > 0) {
header("Location: ".sprintf($url, 'index'));
}
}
$ok = 0;
if($_POST["submit"]) {
$ok = 1;
if(empty($_POST['onderwerp']))
$err[] = "You've forgotten your subject!";
if(empty($_POST['naam']))
$err[] = "You've forgotten your name!";
if(empty($_POST['bericht']))
$err[] = "You've forgotten your message!";
for($i=0;$i<sizeof($bad_words);$i++)
if(ereg($bad_words[$i], $_POST['naam']) || ereg($bad_words[$i], $_POST['onderwerp']) || ereg($bad_words[$i], $_POST['bericht']))
$err[] = "We like to keep our forum desent. Please use some normal language!";
if(sizeof($err) > 0) {
?>
<table width="580" border=0 cellspacing=0 cellpadding=0>
<tr><td class="MainTD">
<table width="100%" border=0 cellspacing=1 cellpadding=3>
<tr>
<td class="HeaderText">Error:</td>
</tr>
<tr>
<td valign="top" align="left" class="NormalText">
<form method="POST" action="<?=sprintf($url, 'message')?>">
<input type="hidden" name="onderwerp" value="<?=$_POST['onderwerp']?>">
<input type="hidden" name="naam" value="<?=$_POST['naam']?>">
<input type="hidden" name="bericht" value="<?=$_POST['bericht']?>">
<input type="hidden" name="reply" value="<?=$_POST['reply']?>">
Something went wrong. Please take attention to the errors below.<br><br>
<?
for($i=0;$i<=sizeof($err);$i++)
echo "\n\t<font class=\"Error\">".$err[$i]."</font><br>";
?>
<input type="submit" value="Back">
</form>
</td>
</tr>
</table>
</td></tr>
</table>
<?
} else {
$sql = "INSERT INTO forum (id, onderwerp, naam, bericht, date_submit, replyop) VALUES ('', '".mysql_escape_string($_POST['onderwerp'])."', '".mysql_escape_string($_POST['naam'])."', '".mysql_escape_string($_POST['bericht'])."', NOW(), '".$reply."')";
mysql_query($sql) or die("<h1>Something went wrong</h1><hr>".mysql_error());
if($_POST['reply'] <> 0) {
$sql = "UPDATE forum SET replys = replys + 1 WHERE id = '".mysql_escape_string($_POST['reply'])."'";
mysql_query($sql) or die("<h1>Something went wrong</h1><hr>".mysql_error());
}
if(!$_POST['reply'])
header("Location: ".sprintf($url, 'index'));
else
header("Location: ".sprintf($url, 'read')."&id=".$_POST['reply']);
}
} else {
?>
<table width="580" border=0 cellspacing=0 cellpadding=0>
<tr><td class="MainTD">
<table width="100%" border=0 cellspacing=1 cellpadding=3>
<tr>
<td class="HeaderText"><br></td>
</tr>
<tr>
<td valign="top" align="left" class="NormalText">
<form name="postform" onsubmit="SubmitOnce(this);" method="POST" action="<?=sprintf($url, 'message')?>">
Uw naam:<br>
<input type="text" name="naam" value="<?=$_POST['naam']?>"><br>
Onderwerp:<br>
<input type="text" name="onderwerp" value="<?=$_POST['onderwerp']?>"><br>
Uw bericht:<br>
<textarea name="bericht" rows="8" cols="40"><?=$_POST['bericht']?></textarea><br>
<input type="hidden" name="reply" value="<?=$_REQUEST['reply']?>">
<input type="hidden" name="submit" value="true">
<input type="submit" value="Toevoegen">
<input type="reset" value="Leegmaken">
</form>
</td>
</tr>
</table>
</td></tr>
</table>
<?
}
?>
read.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
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
<?
if($_REQUEST['id']){
?>
<table width="580" border=0 cellspacing=0 cellpadding=0>
<tr><td class="MainTD">
<table width="100%" border=0 cellspacing=1 cellpadding=3>
<tr>
<td class="HeaderText"><br></td>
</tr>
<?
$sql = "SELECT *, DATE_FORMAT(date_submit, '".$date_format."') AS date_written FROM forum WHERE id = '".mysql_escape_string($_REQUEST['id'])."' ORDER BY date_submit DESC";
$res = mysql_query($sql);
$row = mysql_fetch_array($res);
echo "<tr bgcolor=\"FFFFFF\">\n";
echo "<td valign=top align=left class=\"NormalText\">\n";
echo "<b>Onderwerp:</b> ".htmlspecialchars($row["onderwerp"])."<br>\n";
echo "<b>Door:</b> ".htmlspecialchars($row["naam"])."<br>\n";
echo "<b>Gepost op:</b> ".$row["date_written"]."<br>\n";
echo "<b>Bericht:</b><br>".MaakOp($row["bericht"])."</td>\n";
echo "</tr>\n";
?>
</table>
</td></tr>
</table><br>
</table>
<table width="580" border=0 cellspacing=0 cellpadding=0>
<tr><td class="MainTD">
<table width="100%" border=0 cellspacing=1 cellpadding=3>
<tr>
<td class="HeaderText">Antwoorden</td>
</tr>
<?
$ond = $row["onderwerp"];
$sql = "SELECT *, DATE_FORMAT(date_submit, '".$date_format."') AS date_written FROM forum WHERE replyop = '".mysql_escape_string($_REQUEST['id'])."' ORDER BY date_submit DESC";
$res = mysql_query($sql);
if(mysql_num_rows($res) == 0){
echo "<tr bgcolor=\"FFFFFF\">\n";
echo "<td valign=top align=left class=\"NormalText\">\n";
echo "Nog geen antwoorden\n";
echo "</tr>\n";
} else {
while($row = mysql_fetch_object($res)){
echo "<tr bgcolor=\"FFFFFF\">\n";
echo "<td valign=top align=left class=\"NormalText\">\n";
echo "<b>Onderwerp:</b> ".htmlspecialchars($row->onderwerp)."<br>\n";
echo "<b>Door:</b> ".htmlspecialchars($row->naam)."<br>\n";
echo "<b>Gepost op:</b> ".$row->date_written."<br>\n";
echo "<b>Bericht:</b><br> ".MaakOp($row->bericht)."</td>\n";
echo "</tr>\n";
}
}
?>
</table>
</td></tr>
</table>
<table width="580" border=0 cellspacing=0 cellpadding=0>
<tr>
<td height="20" align="right">
<a href="<?=sprintf($url, 'index')?>">Terug naar het forum</a> | <a href="<?=sprintf($url, 'message')?>&reply=<?=$_REQUEST['id']?>">Beantwoord dit bericht</a>
</td>
</tr>
</table>
<?
}
else {
header("Location: ".sprintf($url, 'index'));
}
?>
if($_REQUEST['id']){
?>
<table width="580" border=0 cellspacing=0 cellpadding=0>
<tr><td class="MainTD">
<table width="100%" border=0 cellspacing=1 cellpadding=3>
<tr>
<td class="HeaderText"><br></td>
</tr>
<?
$sql = "SELECT *, DATE_FORMAT(date_submit, '".$date_format."') AS date_written FROM forum WHERE id = '".mysql_escape_string($_REQUEST['id'])."' ORDER BY date_submit DESC";
$res = mysql_query($sql);
$row = mysql_fetch_array($res);
echo "<tr bgcolor=\"FFFFFF\">\n";
echo "<td valign=top align=left class=\"NormalText\">\n";
echo "<b>Onderwerp:</b> ".htmlspecialchars($row["onderwerp"])."<br>\n";
echo "<b>Door:</b> ".htmlspecialchars($row["naam"])."<br>\n";
echo "<b>Gepost op:</b> ".$row["date_written"]."<br>\n";
echo "<b>Bericht:</b><br>".MaakOp($row["bericht"])."</td>\n";
echo "</tr>\n";
?>
</table>
</td></tr>
</table><br>
</table>
<table width="580" border=0 cellspacing=0 cellpadding=0>
<tr><td class="MainTD">
<table width="100%" border=0 cellspacing=1 cellpadding=3>
<tr>
<td class="HeaderText">Antwoorden</td>
</tr>
<?
$ond = $row["onderwerp"];
$sql = "SELECT *, DATE_FORMAT(date_submit, '".$date_format."') AS date_written FROM forum WHERE replyop = '".mysql_escape_string($_REQUEST['id'])."' ORDER BY date_submit DESC";
$res = mysql_query($sql);
if(mysql_num_rows($res) == 0){
echo "<tr bgcolor=\"FFFFFF\">\n";
echo "<td valign=top align=left class=\"NormalText\">\n";
echo "Nog geen antwoorden\n";
echo "</tr>\n";
} else {
while($row = mysql_fetch_object($res)){
echo "<tr bgcolor=\"FFFFFF\">\n";
echo "<td valign=top align=left class=\"NormalText\">\n";
echo "<b>Onderwerp:</b> ".htmlspecialchars($row->onderwerp)."<br>\n";
echo "<b>Door:</b> ".htmlspecialchars($row->naam)."<br>\n";
echo "<b>Gepost op:</b> ".$row->date_written."<br>\n";
echo "<b>Bericht:</b><br> ".MaakOp($row->bericht)."</td>\n";
echo "</tr>\n";
}
}
?>
</table>
</td></tr>
</table>
<table width="580" border=0 cellspacing=0 cellpadding=0>
<tr>
<td height="20" align="right">
<a href="<?=sprintf($url, 'index')?>">Terug naar het forum</a> | <a href="<?=sprintf($url, 'message')?>&reply=<?=$_REQUEST['id']?>">Beantwoord dit bericht</a>
</td>
</tr>
</table>
<?
}
else {
header("Location: ".sprintf($url, 'index'));
}
?>
Sql:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
CREATE TABLE forum (
id mediumint(9) NOT NULL auto_increment,
onderwerp varchar(100) NOT NULL,
naam varchar(100) NOT NULL,
bericht text NOT NULL,
date_submit datetime NOT NULL,
replyop mediumint(9) DEFAULT '0' NOT NULL,
replys int(11) DEFAULT '0' NOT NULL,
PRIMARY KEY (id),
UNIQUE id (id)
);
id mediumint(9) NOT NULL auto_increment,
onderwerp varchar(100) NOT NULL,
naam varchar(100) NOT NULL,
bericht text NOT NULL,
date_submit datetime NOT NULL,
replyop mediumint(9) DEFAULT '0' NOT NULL,
replys int(11) DEFAULT '0' NOT NULL,
PRIMARY KEY (id),
UNIQUE id (id)
);
Kan iemand mij hiervoor helpen aub ....
Gewijzigd op 01/01/1970 01:00:00 door Kristof Debleu
Google -> Van Dale woordenboek -> Relevant
Wat wil je hiermee zeggen?
P.S. weet iemand hoe ik alles in de php tags kan krijgen? Want zo ziet het er niet uit ....
En jij zoekt de tags
Gewijzigd op 01/01/1970 01:00:00 door Kristof Debleu
En [ignore] en [/ignore] om ubb tags te negeren ;)
Kristof Debleu schreef op 14.01.2008 15:16:
Dat ruim 200 regels code wat overdreven is. als daar 10 tot 20 relevante regels code tussen zitten, dan houdt het echt wel op.@ Jacco
Wat wil je hiermee zeggen?
Wat wil je hiermee zeggen?
Kortom, gooi het grootste gedeelte even weg.
Probleem is opgelost. Deze topic mag gesloten worden ....