login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > PHP > Fora/Discussieborden > Forum 1.3

Forum 1.3

Auteur: FangorN - 31 augustus 2004 - 19:39 - Gekeurd door: Dennisvb - Hits: 24020 - Aantal punten: 4.31 (45 stemmen)



Opmerkingen:
* Voordat het forum werkt, dien je ZELF ten minste één categorie aan te maken
dit doe je rechtstreeks in de database - of je gebruikt de nog-zelf-te-beveiligen
pagina addcategory.php
* categorieen.php is de 'startplaats' van het forum, NIET forum.php

Code:
config.php
-------------------------------------------------------------------
  1. <?php
  2. // make connection
  3. if(mysql_connect("host", "user", "pass")) {
  4. mysql_select_db("database");
  5. } else {
  6. echo "connection to database failed.\n";
  7. exit;
  8. }
  9.  
  10. // name of forum
  11. $forumname = "Forum 1.3";
  12.  
  13. // maximum number of topics per page
  14. $max = 10;
  15.  
  16. // colors used for topicrows
  17. $kleur1 ="#eeeeee";
  18. $kleur2 ="#cccccc";
  19.  
  20. // Na hoeveel posten moet het mapje branden en warm?
  21. $mapwarm = 10;
  22. $mapbrand = 20;
  23.  
  24. // stel hier je fototjes in bv. nieuws_map.gif
  25. $gif1 = "new_thread.gif";
  26. $gif2 = "thread.gif";
  27. $gif3 = "hot_thread.gif";
  28. ?>


style.css
-------------------------------------------------------------------
  1. BODY {FONT-FAMILY: Verdana, Arial, Helvetica;
  2. FONT-SIZE: 8pt;
  3. COLOR: #000000;}
  4.  
  5. TABLE, TD {BORDER-STYLE: solid;
  6. BORDER-COLOR: #aaaaaa;
  7. BORDER-WIDTH: 1px;}
  8.  
  9. TD {FONT-FAMILY: Verdana, Arial, Helvetica;
  10. FONT-SIZE: 8pt;
  11. COLOR: #000000;}
  12.  
  13. A:LINK {FONT-WEIGHT: bold;
  14. TEXT-DECORATION: underline;
  15. COLOR: #ff0000;}
  16.  
  17. A:VISITED {FONT-WEIGHT: bold;
  18. TEXT-DECORATION: underline;
  19. COLOR: #ff0000;}
  20.  
  21. A:ACTIVE {FONT-WEIGHT: bold;
  22. TEXT-DECORATION: underline;
  23. COLOR: #ff0000;}
  24.  
  25. A:HOVER {FONT-WEIGHT: bold;
  26. TEXT-DECORATION: underline;
  27. COLOR: #ff0000;}
  28.  
  29. .def {FONT-FAMILY: Verdana, Arial, Helvetica;
  30. FONT-SIZE: 8pt;
  31. COLOR: #000000;}
  32.  
  33. .tf {BORDER-STYLE: none;
  34. BORDER-WIDTH: 0;}


addcategory.php
-------------------------------------------------------------------
  1. <?php
  2. include("config.php");
  3. ?>
  4. <HTML>
  5. <HEAD>
  6. <TITLE><?php echo $forumname; ?></TITLE>
  7. <LINK HREF="style.css" TYPE="text/css" REL="stylesheet">
  8. </HEAD>
  9.  
  10. <BODY>
  11. <?php
  12. // LET OP !
  13. // Omdat niet iedereen categorieën zou mogen toevoegen, word hier (met
  14. // behulp van de *** login check ***) bepaald of iemand toegang krijgt tot
  15. // het categorie-toevoeg deel. Het is de verantwoordelijkheid van de
  16. // programmeur/webmaster om ervoor te zorgen dat dit stuk beveiligd wordt.
  17.  
  18. if(*** login check ***) {
  19. echo "Log in first.<BR>\n";
  20. } else {
  21. if(!isset($_POST['submit'])) {
  22. // bepaal nummer van laatste toegevoegde categorie en
  23. // tel hier 1 bij op. Hiervoor had het id-veld in de
  24. // tabel categories ook auto_increment kunnen zijn...
  25. $res = mysql_query("SELECT MAX(id) FROM categories") or die(mysql_error());
  26. if(mysql_num_rows($res)) {
  27. $id = mysql_result($res, 0) + 1;
  28. } else {
  29. // er waren blijkbaar nog geen categorieen
  30. $id = 0;
  31. }
  32. ?>
  33. <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2">
  34. <TR>
  35. <TD WIDTH="500" COLSPAN="2"><B><?php echo $forumname; ?> &gt; Categorie toevoegen</B><BR></TD>
  36. </TR>
  37. <TR>
  38. <FORM ACTION="" METHOD="post">
  39. <TD WIDTH="125">naam<BR></TD>
  40. <TD WIDTH="375"><INPUT TYPE="text" NAME="naam" SIZE="40" MAXLENGTH="100"><BR></TD>
  41. </TR>
  42. <TR>
  43. <TD WIDTH="125">omschrijving<BR></TD>
  44. <TD WIDTH="375"><INPUT TYPE="text" NAME="descr" SIZE="40" MAXLENGTH="200"><BR></TD>
  45. </TR>
  46. <TR>
  47. <TD COLSPAN="2">
  48. <INPUT TYPE="hidden" NAME="id" VALUE="<?php echo $id; ?>">
  49. <INPUT TYPE="submit" NAME="submit" VALUE="submit"><BR>
  50. </TD>
  51. </FORM>
  52. </TR>
  53. </TABLE>
  54. <?php
  55. } else {
  56. $naam = $_POST['naam'];
  57. $descr = $_POST['descr'];
  58. $id = $_POST['id'];
  59.  
  60. $error = "";
  61. if(trim($naam) == "") $error = "Geen naam ingevuld...";
  62. elseif(trim($descr) == "") $error = "Geen omschrijving ingevuld...";
  63.  
  64. if($error == "") {
  65. // update database
  66. $naam = htmlentities($naam);
  67.  
  68. $descr = htmlentities($descr);
  69. mysql_query("INSERT INTO categories (id, naam, descr) VALUES ($id, '$naam', '$descr')") or die(mysql_error());
  70. echo "Succes!<BR>\n";
  71. echo "De categorie is toegevoegd.<BR>\n";
  72. echo "<A HREF=\"categorieen.php\">naar categorieen</A><BR>\n";
  73. } else {
  74. // errors!
  75. echo "ERROR: ".$error."<BR>\n";
  76. echo "Druk op de \"back\" knop van je browser.<BR>\n";
  77. }
  78. }
  79. } // end login test
  80. ?>
  81. </BODY>
  82. </HTML>


categorieen.php
-------------------------------------------------------------------
  1. <?php
  2. include("config.php");
  3. ?>
  4. <HTML>
  5. <HEAD>
  6. <TITLE><?php echo $forumname; ?> - categorieën</TITLE>
  7. <LINK HREF="style.css" TYPE="text/css" REL="stylesheet">
  8. </HEAD>
  9.  
  10. <BODY>
  11. <B><?php echo $forumname; ?></B><BR>
  12. <BR>
  13. <TABLE WIDTH="500" BORDER="1" CELLSPACING="0" CELLPADDING="2">
  14. <?php
  15. $query = mysql_query("SELECT * FROM categories ORDER BY id ASC") or die(mysql_error());
  16. if(mysql_num_rows($query)) {
  17. while($row = mysql_fetch_row($query)) {
  18.  
  19. $cat = $row[0];
  20. echo "<TR><TD WIDTH=\"500\">\n";
  21. // topic name
  22. echo "<A HREF=\"forum.php?cat=".$cat."\">".$row[1]."</A> ";
  23.  
  24. // number of topics
  25. $topics = mysql_query("SELECT COUNT(*) FROM forum WHERE cat=$cat") or die(mysql_error());
  26. echo "(".mysql_result($topics, 0).")<BR>\n";
  27. mysql_free_result($topics);
  28.  
  29. // description of each topic
  30. echo $row[2]."<BR>\n";
  31. echo "</TD></TR>\n";
  32. }
  33. } else {
  34. echo "<TR><TD WIDTH=\"500\">\n";
  35. echo "Er zijn nog geen categorieën.<BR>\n";
  36. echo "</TD></TR>\n";
  37. }
  38. ?>
  39. </TABLE>
  40. </BODY>
  41. </HTML>


forum.php
-------------------------------------------------------------------
  1. <?php
  2. include ("config.php");
  3.  
  4. $cat = $_GET['cat'];
  5. $pagina = (isset($_GET['pagina']) ? $_GET['pagina'] : 0);
  6. ?>
  7. <HTML>
  8. <HEAD>
  9. <TITLE><?php echo $forumname; ?></TITLE>
  10. <LINK HREF="style.css" TYPE="text/css" REL="stylesheet">
  11. </HEAD>
  12.  
  13. <BODY>
  14. <?php
  15. $query = mysql_query("SELECT naam FROM categories WHERE id=$cat") or die(mysql_error());
  16.  
  17. // category check
  18. if(!mysql_num_rows($query)) {
  19. echo "<CENTER>De geselecteerde categorie bestaat niet (meer).<BR>\n";
  20. echo "<A HREF=\"categorieen.php\">Terug naar Categorieën</A><BR></CENTER>\n";
  21. } else {
  22. echo "<A HREF=\"categorieen.php\">".$forumname."</A> &gt; <B>".mysql_result($query, 0, "naam")."</B><BR>\n";
  23. ?>
  24. <BR>
  25. <TABLE WIDTH="500" BORDER="1" CELLSPACING="0" CELLPADDING="2">
  26. <?php
  27. $query1 = mysql_query("SELECT COUNT(*) FROM forum WHERE cat=$cat") or die(mysql_error());
  28. $aantal_berichten = mysql_result($query1, 0);
  29.  
  30. $start = $pagina * $max;
  31. $query2 = mysql_query("SELECT * FROM forum where cat=$cat ORDER BY id DESC LIMIT $start, $max") or die(mysql_error());
  32.  
  33. if(mysql_num_rows($query2)) {
  34. $i = 0;
  35. ?>
  36. <TR>
  37. <TD WIDTH="25">
  38. <BR>
  39. </TD>
  40.  
  41. <TD WIDTH="200">
  42. <B>Titel</B><BR>
  43. </TD>
  44.  
  45. <TD WIDTH="100" ALIGN="center">
  46. <B>Gepost door</B><BR>
  47. </TD>
  48.  
  49. <TD WIDTH="100" ALIGN="center">
  50. <B>Gepost op<B><BR>
  51. </TD>
  52.  
  53. <TD WIDTH="75" ALIGN="center">
  54. <B>Reacties</B><BR>
  55. </TD>
  56. </TR>
  57. <?php
  58. while($row = mysql_fetch_row($query2)) {
  59. $forumid = $row[0];
  60. $query3 = mysql_query("SELECT COUNT(*) FROM forumreplys WHERE forumid=$forumid") or die("q3: ".mysql_error());
  61. $replys = mysql_result($query3, 0);
  62. if($replys == 0) {
  63. $thread = $gif1;
  64. } elseif($replys > 0 && $replys < $mapbrand) {
  65. $thread = $gif2;
  66. } elseif($replys >= $mapbrand) {
  67. $thread = $gif3;
  68. }
  69.  
  70. // per rij zal het van kleur verwisselen
  71. $kleur = ($i % 2 ? $kleur1 : $kleur2); //aanpassen in config
  72. echo "<TR BGCOLOR=\"".$kleur."\">";
  73. echo "<TD WIDTH=\"25\" ALIGN=\"center\"><IMG SRC=\"".$thread."\" WIDTH=\"13\" HEIGHT=\"16\" ALT=\"";
  74. echo $row[7]." hit".($row[7] == 1 ? "" : "s")."\"><BR></TD>";
  75. echo "<TD WIDTH=\"200\"><A HREF=\"forumbericht.php?cat=".$cat."&forumid=$forumid\">".$row[1]."</A><BR></TD>";
  76. echo "<TD WIDTH=\"100\" ALIGN=\"center\"><A HREF=\"mailto:".$row[5]."\">".$row[3]."</A></TD>";
  77. echo "<TD WIDTH=\"100\" ALIGN=\"center\">".date("d/m/Y H:i", $row[4])."</TD>";
  78. echo "<TD WIDTH=\"75\" ALIGN=\"center\">".$replys."</TD></TR>";
  79. $i++;
  80. } // end while
  81. mysql_free_result($query2);
  82. ?>
  83.  
  84. <?php
  85. // navigatie
  86. if($aantal_berichten > $max) {
  87. // laat alleen navigatie zien als er meer berichten zijn dan dat er op een pagina passen
  88. // aantal pagina's:
  89. if(!($aantal_berichten % $max)) {
  90. // pagina's passen precies
  91. $npaginas = $aantal_berichten/$max;
  92. } else {
  93. // rest na deling
  94. $npaginas = (integer)($aantal_berichten/$max) + 1;
  95. }
  96. echo "<TR><TD WIDTH=\"500\" COLSPAN=\"5\" ALIGN=\"center\">\n";
  97. echo "Pagina's ";
  98. for($p=0; $p < $npaginas; $p++) {
  99. if($p == $pagina) {
  100. echo "<B>$p</B>";
  101. } else {
  102. echo "<A HREF=\"forum.php?pagina=".$p."&cat=".$cat."\">".$p."</A>";
  103. }
  104. echo (($p+1) < $npaginas ? "|" : "");
  105. }
  106. echo "</TD></TR>\n";
  107. }
  108. } elseif(!$pagina) {
  109. // nog geen forumids in deze categorie OF
  110. // een persoon zit op een niet-bestaande pagina
  111. ?>
  112. <TR>
  113. <TD WIDTH="500" COLSPAN="5" ALIGN="center">
  114. <B>Er zijn nog geen forumberichten toegevoegd in deze categorie!</B>
  115. </TD>
  116. </TR>
  117. <?php
  118. } else {
  119. ?>
  120. <TR>
  121. <TD WIDTH="500" COLSPAN="5" ALIGN="center">
  122. <B>Er staan geen berichten op deze pagina!</B>
  123. </TD>
  124. </TR>
  125. <?php
  126. }
  127. ?>
  128. <TR>
  129. <TD COLSPAN="5" ALIGN="center">
  130. <A HREF="nieuwbericht.php?cat=<?php echo $cat; ?>">Nieuw Topic</A> |
  131. <A HREF="categorieen.php">Terug naar '<?php echo $forumname; ?>'</A><BR>
  132. </TD>
  133. </TR>
  134. </TABLE>
  135. <?php
  136. } // end category exists check
  137. ?>
  138. </BODY>
  139. </HTML>


forumbericht.php
-------------------------------------------------------------------
  1. <?php
  2. include ("config.php");
  3.  
  4. $cat = $_GET['cat'];
  5. $forumid = $_GET['forumid'];
  6. ?>
  7. <HTML>
  8. <HEAD>
  9. <TITLE><?php echo $forumname; ?></TITLE>
  10. <LINK HREF="style.css" TYPE="text/css" REL="stylesheet">
  11. </HEAD>
  12.  
  13. <BODY>
  14. <?php
  15. $query = mysql_query("SELECT naam FROM categories WHERE id=$cat") or die(mysql_error());
  16. if(!mysql_num_rows($query)) {
  17. echo "<CENTER>De geselecteerde categorie bestaat niet (meer).<BR>\n";
  18. echo "<A HREF=\"categorieen.php\">Terug naar Categorieën</A><BR></CENTER>\n";
  19. } else {
  20. $naam = mysql_result($query, 0, "naam");
  21. echo "<A HREF=\"categorieen.php\">".$forumname."</A> &gt; ";
  22. echo "<A HREF=\"forum.php?cat=".$cat."\">".$naam."</A>";
  23.  
  24. $res = mysql_query("SELECT * FROM forum where id=$forumid") or die(mysql_error());
  25. if(!mysql_num_rows($res)) {
  26. echo "<CENTER>Het geselecteerde forumid bestaat niet (meer).<BR>\n";
  27. echo "<A HREF=\"forum.php?cat=".$cat."\">Terug naar '".$naam."'</A><BR></CENTER>\n";
  28. } else {
  29. mysql_query("UPDATE forum SET hits=hits+1 where id=$forumid") or die(mysql_error());
  30. if(mysql_num_rows($res)) {
  31. $row = mysql_fetch_row($res);
  32. echo " &gt; <B>".$row[1]."</B><BR>\n";
  33. ?>
  34. <BR>
  35. <TABLE WIDTH="500" BORDER="1" CELLSPACING="0" CELLPADDING="2">
  36. <TR>
  37. <TD WIDTH="500">
  38. <B>Onderwerp:</B> <?php echo $row[1]; ?><BR>
  39. </TD>
  40. </TR>
  41.  
  42. <TR>
  43. <TD WIDTH="500">
  44. <B>Gepost door:</B> <?php echo "<A HREF=\"mailto:".$row[5]."\">".$row[3]."</A>"; ?><BR>
  45. <B>Gepost op:</B> <?php echo date("d/m/Y H:i", $row[4]); ?>
  46. </TD>
  47. </TR>
  48.  
  49. <TR>
  50. <TD WIDTH="500">
  51. <?php
  52. echo nl2br($row[6]);
  53. ?>
  54. </TD>
  55. </TR>
  56. </TABLE>
  57.  
  58. <br>
  59. <?php
  60. $res2 = mysql_query("SELECT * FROM forumreplys where forumid=$forumid") or die(mysql_error());
  61.  
  62. if (mysql_num_rows($res2)) {
  63. while($row = mysql_fetch_row($res2)) {
  64. ?>
  65. <TABLE WIDTH="500" BORDER="1" CELLSPACING="0" CELLPADDING="2">
  66. <TR>
  67. <TD WIDTH="500">
  68. <B>Reply:</B> <?php echo $row[2]; ?><BR>
  69. </TD>
  70. </TR>
  71.  
  72. <TR>
  73. <TD WIDTH="500">
  74. <B>Gepost door:</B> <?php echo "<A HREF=\"mailto: ".$row[4]."\">".$row[3]."</A>"; ?><BR>
  75. <B>Gepost op:</B> <?php echo date("d/m/Y H:i", $row[5]); ?><BR>
  76. </TD>
  77. </TR>
  78.  
  79. <TR>
  80. <TD WIDTH="500">
  81. <?php
  82. echo nl2br($row[6]);
  83. ?>
  84. </TD>
  85. </TR>
  86. </TABLE>
  87. <BR>
  88. <?php
  89. } // end while
  90. } // end $aantal > 0
  91. } // end message exists
  92. ?>
  93. <BR>
  94. <TABLE WIDTH="500" BORDER="1" CELLSPACING="0" CELLPADDING="2">
  95. <TR>
  96. <TD WIDTH="500" ALIGN="center">
  97. <A HREF="postreactie.php?cat=<?php echo $cat."&forumid=".$forumid; ?>">Post Reactie</A> |
  98. <A HREF="nieuwbericht.php?cat=<?php echo $cat; ?>">Nieuw Topic</A> |
  99. <A HREF="forum.php?cat=<?php echo $cat; ?>">Terug naar '<?php echo $naam; ?>'</A><BR>
  100. </TD>
  101. </TR>
  102. </TABLE>
  103. <?php
  104. } // end forumid exists check
  105. } // end category exists check
  106. ?>
  107. </BODY>
  108. </HTML>


nieuwbericht.php
-------------------------------------------------------------------
  1. <?php
  2. include ("config.php");
  3. $cat = $_GET['cat'];
  4. ?>
  5. <HTML>
  6. <HEAD>
  7. <TITLE><?php echo $forumname; ?></TITLE>
  8. <LINK HREF="style.css" TYPE="text/css" REL="stylesheet">
  9. </HEAD>
  10.  
  11. <BODY>
  12. <?php
  13. $query = mysql_query("SELECT naam FROM categories WHERE id=$cat") or die("q: ".mysql_error());
  14. if(!mysql_num_rows($query)) {
  15. echo "<CENTER>De geselecteerde categorie bestaat niet (meer).<BR>\n";
  16. echo "<A HREF=\"categorieen.php\">Terug naar Categorieën</A><BR></CENTER>\n";
  17. } else {
  18. $naam = mysql_result($query, 0, "naam");
  19. echo "<A HREF=\"categorieen.php\">".$forumname."</A> &gt; ";
  20. echo "<A HREF=\"forum.php?cat=".$cat."\">".$naam."</A> &gt; <B>Nieuw bericht</B><BR>\n";
  21. ?>
  22. <BR>
  23. <TABLE WIDTH="500" BORDER="1" CELLSPACING="0" CELLPADDING="2">
  24. <TR>
  25. <TD WIDTH="500" ALIGN="center">
  26. <?php
  27. if ($_POST['submit']) {
  28. $error = "";
  29. if(trim($_POST['naam']) == "") $error = "Je moet een naam invullen<BR><BR>";
  30. elseif(trim($_POST['email']) == "") $error = "Je moet je emailadres invullen<BR><BR>";
  31. elseif(trim($_POST['titel']) == "") $error = "Je moet een titel invullen<BR><BR>";
  32. elseif(trim($_POST['bericht']) == "") $error = "Je moet een bericht invullen<BR><BR>";
  33. if (!$error) {
  34. $titel = htmlentities($_POST['titel']);
  35. $naam = htmlentities($_POST['naam']);
  36. $datum = time();
  37. $email = htmlentities($_POST['email']);
  38. $bericht = htmlentities($_POST['bericht']);
  39.  
  40. $query = "INSERT INTO forum (id, titel, cat, naam, datum, email, bericht, hits)
  41. VALUES ('', '$titel', $cat, '$naam', $datum, '$email', '$bericht', 0)";
  42. mysql_query($query) or die(mysql_error());
  43.  
  44. echo "Het bericht is verzonden.<BR>\n";
  45. echo "klik <A HREF=\"forum.php?cat=".$cat."\">hier</A> om terug naar het forum te gaan.<BR>\n";
  46. } else {
  47. // errors
  48. echo "<B>".$error."</B><BR>\n";
  49. echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."?cat=".$cat."\" METHOD=\"post\">\n";
  50. echo "<INPUT TYPE=\"submit\" VALUE=\"Terug\">\n";
  51. echo "</FORM>";
  52. }
  53. } else {
  54. ?>
  55. <TABLE CLASS="tf" WIDTH="500" BORDER="0" CELLSPACING="0" CELLPADDING="2">
  56. <FORM ACTION="<?php echo $_SERVER['PHP_SELF']."?cat=".$cat; ?>" METHOD="post">
  57. <TR>
  58. <TD CLASS="tf" WIDTH="125" ALIGN="right"><B>Naam</B>&nbsp;</TD>
  59. <TD CLASS="tf" WIDTH="375"><INPUT TYPE="text" CLASS="def" NAME="naam" SIZE="30" MAXLENGTH="30"></TD>
  60. </TR>
  61.  
  62. <TR>
  63. <TD CLASS="tf" WIDTH="125" ALIGN="right"><B>Email</B>&nbsp;</TD>
  64. <TD CLASS="tf" WIDTH="375"><INPUT TYPE="text" CLASS="def" NAME="email" SIZE="30" MAXLENGTH="50"></TD>
  65. </TR>
  66.  
  67. <TR>
  68. <TD CLASS="tf" WIDTH="125" ALIGN="right"><B>Titel</B>&nbsp;</TD>
  69. <TD CLASS="tf" WIDTH="375"><INPUT TYPE="text" CLASS="def" NAME="titel" SIZE="30" MAXLENGTH="50"></TD>
  70. </TR>
  71.  
  72. <TR>
  73. <TD CLASS="tf" WIDTH="125" ALIGN="right" VALIGN="top"><B>Bericht</B>&nbsp;</TD>
  74. <TD CLASS="tf" WIDTH="375"><TEXTAREA NAME="bericht" CLASS="def" COLS="30" ROWS="4"></TEXTAREA><BR></TD>
  75. </TR>
  76.  
  77. <TR>
  78. <TD CLASS="tf" WIDTH="500" COLSPAN="2" ALIGN="center">
  79. <INPUT TYPE="submit" CLASS="def" NAME="submit" VALUE="Post topic">
  80. </TD>
  81. </TR>
  82. </FORM>
  83. </TABLE>
  84.  
  85. <?php
  86. } // end else
  87. ?>
  88. <BR>
  89. </TD>
  90. </TR>
  91.  
  92. <TR>
  93. <TD WIDTH="500" ALIGN="center"><A HREF="forum.php?cat=<?php echo $cat; ?>">Terug naar Forum</A></TD>
  94. </TR>
  95. </TABLE>
  96. <?php
  97. } // end category exists check
  98. ?>
  99. </BODY>
  100. </HTML>


postreactie.php
-------------------------------------------------------------------
  1. <?php
  2. include("config.php");
  3. $cat = $_GET['cat'];
  4. $forumid = $_GET['forumid'];
  5. ?>
  6. <HTML>
  7. <HEAD>
  8. <TITLE><?php echo $forumname; ?></TITLE>
  9. <LINK HREF="style.css" TYPE="text/css" REL="stylesheet">
  10. </HEAD>
  11.  
  12. <BODY>
  13. <?php
  14. $query = mysql_query("SELECT naam FROM categories WHERE id=$cat") or die(mysql_error());
  15. if(!mysql_num_rows($query)) {
  16. echo "<CENTER>De geselecteerde categorie bestaat niet (meer).<BR>\n";
  17. echo "<A HREF=\"categorieen.php\">Terug naar Categorieën</A><BR></CENTER>\n";
  18. } else {
  19. $naam = mysql_result($query, 0, "naam");
  20.  
  21. $res = mysql_query("SELECT * FROM forum where id=$forumid") or die(mysql_error());
  22. if(!mysql_num_rows($res)) {
  23. echo "<CENTER>Het geselecteerde forumid bestaat niet (meer).<BR>\n";
  24. echo "<A HREF=\"forum.php?cat=".$cat."\">Terug naar '".$naam."'</A><BR></CENTER>\n";
  25. } else {
  26. echo "<A HREF=\"categorieen.php\">".$forumname."</A> &gt; ";
  27. echo "<A HREF=\"forum.php?cat=".$cat."\">".$naam."</A> &gt; ";
  28. echo "<B>Post reactie</B><BR>\n";
  29. ?>
  30. <BR>
  31. <TABLE WIDTH="500" BORDER="0" CELLSPACING="0" CELLPADDING="2">
  32. <TR>
  33. <TD WIDTH="500" ALIGN="center">
  34. <?php
  35. if($_POST['submit']) {
  36. if(trim($_POST['naam']) == "") $error = "Je moet je naam invullen<BR><BR>";
  37. elseif(trim($_POST['email']) == "") $error = "Je moet je e-mailadres invullen<BR><BR>";
  38. elseif(trim($_POST['titel']) == "") $error = "Je moet een titel invullen<BR><BR>";
  39. elseif(trim($_POST['bericht']) == "") $error = "Je moet een bericht invullen<BR><BR>";
  40. if (!$error) {
  41. $titel = htmlentities($_POST['titel']);
  42. $naam = htmlentities($_POST['naam']);
  43. $email = htmlentities($_POST['email']);
  44. $datum = time();
  45. $bericht = htmlentities($_POST['bericht']);
  46.  
  47. $query ="INSERT INTO forumreplys (id, forumid, titel, naam, email, datum, bericht)
  48. VALUES ('', $forumid, '$titel', '$naam', '$email', $datum, '$bericht')";
  49. mysql_query($query) or die(mysql_error());
  50. echo "De reactie is verzonden.<BR>\n";
  51. echo "klik <A HREF=\"forumbericht.php?cat=".$cat."&forumid=".$forumid."\">hier</A> ";
  52. echo "om terug naar het forumbericht te gaan.<BR>\n";
  53. } else {
  54. // errors
  55. echo "<B>".$error."</B><BR>\n";
  56. echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."?cat=".$cat."&forumid=".$forumid."\" METHOD=\"post\">\n";
  57. echo "<INPUT TYPE=\"submit\" CLASS=\"def\" VALUE=\"Terug\">\n";
  58. echo "</FORM>";
  59. }
  60. } else {
  61. ?>
  62. <TABLE CLASS="tf" WIDTH="500" BORDER="0" CELLSPACING="0" CELLPADDING="2">
  63. <FORM ACTION="<?php echo $_SERVER['PHP_SELF']."?cat=".$cat."&forumid=".$forumid;?>" METHOD="post">
  64. <TR>
  65. <TD CLASS="tf" WIDTH="125" ALIGN="right"><B>Naam</B>&nbsp;</TD>
  66. <TD CLASS="tf" WIDTH="375"><INPUT TYPE="text" CLASS="def" NAME="naam" SIZE="30" MAXLENGTH="30"></TD>
  67. </TR>
  68.  
  69. <TR>
  70. <TD CLASS="tf" WIDTH="125" ALIGN="right"><B>Email</B>&nbsp;</TD>
  71. <TD CLASS="tf" WIDTH="375"><INPUT TYPE="text" CLASS="def" NAME="email" SIZE="30" MAXLENGTH="50"></TD>
  72. </TR>
  73.  
  74. <TR>
  75. <TD CLASS="tf" WIDTH="125" ALIGN="right"><B>Titel</B>&nbsp;</TD>
  76. <TD CLASS="tf" WIDTH="375"><INPUT TYPE="text" CLASS="def" NAME="titel" SIZE="30" MAXLENGTH="50"></TD>
  77. </TR>
  78.  
  79. <TR>
  80. <TD CLASS="tf" WIDTH="125" ALIGN="right" VALIGN="top"><B>Bericht</B>&nbsp;</TD>
  81. <TD CLASS="tf" WIDTH="375"><TEXTAREA NAME="bericht" CLASS="def" COLS="30" ROWS="4"></TEXTAREA><BR></TD>
  82. </TR>
  83.  
  84. <TR>
  85. <TD CLASS="tf" WIDTH="500" COLSPAN="2" ALIGN="center">
  86. <INPUT TYPE="submit" CLASS="def" NAME="submit" VALUE="Post reactie">
  87. </TD>
  88. </TR>
  89. </FORM>
  90. </TABLE>
  91. <?php
  92. } // end else
  93. ?>
  94. <BR>
  95. </TD>
  96. </TR>
  97.  
  98. <TR>
  99. <TD WIDTH="500" ALIGN="center"><A HREF="forumbericht.php?cat=<?php echo $cat."&forumid=".$forumid; ?>">Terug naar Forum</A></TD>
  100. </TR>
  101. </TABLE>
  102. <?php
  103. } // end forumid exists check
  104. } // end category exists check
  105. ?>
  106. </BODY>
  107. </HTML>


De Mysql db's
--------------------------------------------------

  1. CREATE TABLE categories (
  2. id int(10) NOT NULL,
  3. naam varchar(100) NOT NULL,
  4. descr varchar(200) NOT NULL,
  5. PRIMARY KEY (id)
  6. ) TYPE=MyISAM;
  7.  
  8. CREATE TABLE forum (
  9. id int(10) NOT NULL auto_increment,
  10. titel varchar(50) NOT NULL,
  11. cat int(10) NOT NULL,
  12. naam varchar(30) NOT NULL,
  13. datum int(10) NOT NULL,
  14. email varchar(50) NOT NULL,
  15. bericht text NOT NULL,
  16. hits int(10) NOT NULL,
  17. PRIMARY KEY (id)
  18. ) TYPE=MyISAM;
  19.  
  20. CREATE TABLE forumreplys (
  21. id int(10) NOT NULL auto_increment,
  22. forumid int(10) NOT NULL,
  23. titel varchar(50) NOT NULL,
  24. naam varchar(30) NOT NULL,
  25. email varchar(50) NOT NULL,
  26. datum varchar(10) NOT NULL,
  27. bericht text NOT NULL,
  28. PRIMARY KEY (id)
  29. ) TYPE=MyISAM;
Download code! Download code (.txt)

 Stemmen
Niet ingelogd.

 Reacties
Post een reactie
Lees de reacties (76)
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.157s