kickntodabeat
Nieuwe gebruiker
- Lid geworden
- 14 jan 2008
- Berichten
- 2
Als ik op "Beantwoord dit bericht" klik van mijn forum, post hij een nieuw onderwerp ....
Voorbeeld kan je hier bekijken:
http://www.kristofdebleu.net/qparty/crew/login.php
Inloggen met: demo - demo
index.php
message.php
read.php
Sql:
Kan iemand mij hiervoor helpen aub ....
Voorbeeld kan je hier bekijken:
http://www.kristofdebleu.net/qparty/crew/login.php
Inloggen met: demo - demo
index.php
PHP:
<?
$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
PHP:
<?
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
PHP:
<?
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:
PHP:
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)
);
Kan iemand mij hiervoor helpen aub ....