login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > PHP > Overige scripts > Artikelen systeem

Artikelen systeem

Auteur: Carpmadness - 11 september 2004 - 17:35 - Gekeurd door: Dennisvb - Hits: 10872 - Aantal punten: 3.60 (5 stemmen)



Vrij simpel, config even aanpassen en run install.php

Code:
install.php
  1. <?
  2. require_once('config.php');
  3.  
  4. $tabel = 'CREATE TABLE '.$arr['tnam'].' (
  5. `aid` INT(11) AUTO_INCREMENT PRIMARY KEY,
  6. `aname` VARCHAR(100),
  7. `aauthor` VARCHAR(100),
  8. `aip` VARCHAR(100),
  9. `adate` VARCHAR(100),
  10. `acat` VARCHAR(100),
  11. `acomment` TEXT,
  12. `aartikel` LONGTEXT
  13. )';
  14.  
  15. mysql_query($tabel) or die("Fout bij het installeren");
  16.  
  17. ?>


config.php
  1. <?
  2. $arr['host'] = 'localhost'; // Je host
  3. $arr['user'] = ''; // Je database gebruikers gebruikersnaam
  4. $arr['pass'] = ''; // Je database gebruikers wachtwoord
  5. $arr['dbsl'] = ''; // Je database naam
  6. $arr['tnam'] = 'artikelen'; // Naam van de tabel die je hiervoor gaat gebruiken
  7.  
  8. // Stel de categorien van de artikelen in doormiddel van een array
  9. // Voeg er meer toe door , 'Categorie naam'
  10. // laat de eerste leeg om te zorgen zodat de check of alles is ingevuldt goed functioneert
  11. $arr['arra'] = array('Categorie1', 'Categorie2', 'Categorie3', 'Categorie4', 'Categorie5');
  12.  
  13. // Simpel connecten met de genoemde database
  14. mysql_connect($arr['host'], $arr['user'], $arr['pass'], $arr['dbsl']) or die('Er is helaas iets misgegaan tijdens het connecten met de database '.$arr['dbsl'].' Dit komt door:<br>'.mysql_error());
  15. mysql_select_db($arr['dbsl']);
  16.  
  17. function simpele_ubb($bericht){
  18.  
  19. $bericht = htmlspecialchars($bericht);
  20. // en nog meer ubb
  21. return $bericht;
  22.  
  23. }
  24. ?>


admin.php
  1. <?
  2. ?>
  3. <link href="style.css" rel="stylesheet" type="text/css">
  4. <?
  5. require_once'config.php';
  6. if (isset ($_GET['a'])){
  7.  
  8. if ($_GET['a'] == 'add'){
  9. if (isset($_POST['opslaan'])){
  10. if (!$_POST['aauthor'] || !$_POST['aname'] || !$_POST['acat'] || !$_POST['acomment'] || !$_POST['aartikel']){
  11. echo'Je hebt niet alles ingevuldt..!<br><a href="javascript:history.go(-1)">Klik hier om terug te gaan en om het nog is te proberen';
  12. }else {
  13. $arr['input'] = 'INSERT INTO '.$arr['tnam'].' (aname, aauthor, aip, adate, acat, acomment, aartikel) VALUES ("'.$_POST['aname'].'", "'.$_POST['aauthor'].'", "'.$_SERVER['REMOTE_ADDR'].'", "'.date('d-m-Y | H:i:s').'", "'.$_POST['acat'].'", "'.$_POST['acomment'].'", "'.$_POST['aartikel'].'")';
  14. $arr['putin'] = mysql_query($arr['input']);
  15.  
  16. if ($arr['putin'] === true){
  17. header('location: admin.php');
  18. }else {
  19. echo'Het is helaas niet gelukt om het op te slaan in de database '.$arr['tnam'].'...<br><a href="javascript:history.go(-1)">Klik hier om terug te gaan en om het nog is te proberen</a>';
  20. }
  21. }
  22. }else {
  23.  
  24. ?>
  25. <form action="admin.php?a=add" method="post">
  26. <table width="600" border="0" cellpadding="0" cellspacing="0">
  27. <tr>
  28. <td height="20" colspan="2"><strong>Artikelen Admin Panel :: TOEVOEGEN</strong></td>
  29. </tr>
  30. <tr>
  31. <td height="20" colspan="2">&nbsp;</td>
  32. </tr>
  33. <tr>
  34. <td height="20" colspan="2"><strong>Auteur: </strong></td>
  35. </tr>
  36. <tr>
  37. <td height="20" colspan="2"><strong>
  38. <input name="aauthor" type="text" id="aauthor" size="30">
  39. </strong></td>
  40. </tr>
  41. <tr>
  42. <td height="20" colspan="2"><strong>Artikel naam:</strong></td>
  43. </tr>
  44. <tr>
  45. <td height="20" colspan="2"><strong>
  46. <input name="aname" type="text" id="aname" size="93">
  47. </strong></td>
  48. </tr>
  49. <tr>
  50. <td height="20" colspan="2"><strong>Artikel categorie:</strong></td>
  51. </tr>
  52. <tr>
  53. <td height="20" colspan="2"><strong>
  54. <select name="acat" id="acat">
  55. <?
  56. foreach ($arr['arra'] as $val) {
  57. echo'<option value="'.$val.'">'.$val.'</option>';
  58. }
  59. ?>
  60. </select>
  61. </strong></td>
  62. </tr>
  63. <tr>
  64. <td height="20" colspan="2"><strong>Artikel commentaar:</strong></td>
  65. </tr>
  66. <tr>
  67. <td height="20" colspan="2"><textarea name="acomment" cols="92" rows="5" wrap="VIRTUAL" id="textarea5"></textarea></td>
  68. </tr>
  69. <tr>
  70. <td height="20" colspan="2"><strong>Artikel:</strong> (het hele artikel)</td>
  71. </tr>
  72. <tr>
  73. <td height="20" colspan="2"><textarea name="aartikel" cols="117" rows="30" wrap="VIRTUAL" id="textarea6"></textarea></td>
  74. </tr>
  75. <tr>
  76. <td height="20" colspan="2">&nbsp;</td>
  77. </tr>
  78. <tr>
  79. <td width="300" height="20" valign="middle">
  80. <input name="refresh" type="reset" id="refresh" value="[ Refrehs ]">
  81. </td>
  82. <td width="300" align="center" valign="middle">
  83. <input name="opslaan" type="submit" id="opslaan" value="[ Opslaan ]"></td>
  84. </tr>
  85. <tr>
  86. <td height="20" colspan="2">&nbsp;</td>
  87. </tr>
  88. </table>
  89. </form>
  90. <? }
  91. }else if ($_GET['a'] == 'delete'){
  92. if (isset($_GET['id'])){
  93. if ($_GET['id'] !== ''){
  94. $arr['delete'] = 'DELETE FROM '.$arr['tnam'].' WHERE aid="'.$_GET['id'].'"';
  95. $arr['eteled'] = mysql_query($arr['delete']);
  96. if ($arr['eteled'] === true){
  97. header('location: admin.php');
  98. }else {
  99. echo'Het is helaas niet gelukt om het gewenste artikel te verwijderen uit de tabel '.$arr['tnam'].'...<br><a href="javascript:history.go(-1)">Klik hier om terug te gaan en om het nog is te proberen</a>';
  100. }
  101. }else {
  102. echo'Je moet wel een artikel id kiezen om te verwijderen...<br><a href="javascript:history.go(-1)">Klik hier om terug te gaan en om het nog is te proberen</a>';
  103. }
  104. }
  105.  
  106. }else if ($_GET['a'] == 'edit'){
  107. if (isset($_GET['id'])){
  108. if ($_GET['id'] !== ''){
  109. if (isset($_POST['edit'])){
  110. $arr['update'] = 'UPDATE '.$arr['tnam'].' SET aname="'.$_POST['aname'].'", aip="'.$_SERVER['REMOTE_ADDR'].'", adate="'.date('d-m-Y | H:i:s').'", acat="'.$_POST['acat'].'", acomment="'.$_POST['acomment'].'", aartikel="'.$_POST['aartikel'].'" WHERE aid="'.$_GET['id'].'"';
  111. $arr['dateup'] = mysql_query($arr['update']);
  112.  
  113. if ($arr['dateup'] === true){
  114. header('location: admin.php');
  115. }else {
  116. echo'Het is helaas niet gelukt om het gewenste artikel te verwijderen uit de tabel '.$arr['tnam'].'...<br><a href="javascript:history.go(-1)">Klik hier om terug te gaan en om het nog is te proberen</a>';
  117. }
  118. }else {
  119. $arr['select'] = 'SELECT * FROM '.$arr['tnam'].' WHERE aid="'.$_GET['id'].'"';
  120. $arr['getsel'] = mysql_query($arr['select']);
  121. $arr['info'] = mysql_fetch_object($arr['getsel']);
  122.  
  123. ?>
  124. <form action="admin.php?a=edit&id=<? echo $_GET['id']; ?>" method="post">
  125. <table width="600" border="0" cellpadding="0" cellspacing="0">
  126. <tr>
  127. <td height="20" colspan="2"><strong>Artikelen Admin Panel :: TOEVOEGEN</strong></td>
  128. </tr>
  129. <tr>
  130. <td height="20" colspan="2">&nbsp;</td>
  131. </tr>
  132. <tr>
  133. <td height="20" colspan="2"><strong>Artikel naam:</strong></td>
  134. </tr>
  135. <tr>
  136. <td height="20" colspan="2"><strong>
  137. <input name="aname" type="text" id="aname" size="93" value="<? echo $arr['info']->aname; ?>">
  138. </strong></td>
  139. </tr>
  140. <tr>
  141. <td height="20" colspan="2"><strong>Artikel categorie:</strong></td>
  142. </tr>
  143. <tr>
  144. <td height="20" colspan="2"><strong>
  145. <select name="acat" id="acat">
  146. <option value="<? echo $arr['info']->acat; ?>"><? echo $arr['info']->acat; ?></option>
  147. <?
  148. foreach ($arr['arra'] as $val) {
  149. echo'<option value="'.$val.'">'.$val.'</option>';
  150. }
  151. ?>
  152. </select>
  153. </strong></td>
  154. </tr>
  155. <tr>
  156. <td height="20" colspan="2"><strong>Artikel commentaar:</strong></td>
  157. </tr>
  158. <tr>
  159. <td height="20" colspan="2"><textarea name="acomment" cols="92" rows="5" wrap="VIRTUAL" id="textarea5"><? echo $arr['info']->acomment; ?></textarea></td>
  160. </tr>
  161. <tr>
  162. <td height="20" colspan="2"><strong>Artikel:</strong> (het hele artikel)</td>
  163. </tr>
  164. <tr>
  165. <td height="20" colspan="2"><textarea name="aartikel" cols="117" rows="30" wrap="VIRTUAL" id="textarea6"><? echo $arr['info']->aartikel; ?></textarea></td>
  166. </tr>
  167. <tr>
  168. <td height="20" colspan="2">&nbsp;</td>
  169. </tr>
  170. <tr>
  171. <td width="300" height="20" valign="middle"> <input name="refresh" type="reset" id="refresh" value="[ Refrehs ]">
  172. </td>
  173. <td width="300" align="center" valign="middle"> <input name="edit" type="submit" id="edit" value="[ Bewerk ]"></td>
  174. </tr>
  175. <tr>
  176. <td height="20" colspan="2">&nbsp;</td>
  177. </tr>
  178. </table>
  179. </form>
  180.  
  181. <?
  182.  
  183. }
  184. }else {
  185. echo'Je moet wel een artikel id kiezen om te bewerken...<br><a href="javascript:history.go(-1)">Klik hier om terug te gaan en om het nog is te proberen</a>';
  186. }
  187. }
  188. }else {
  189. header('location: index.php');
  190. }
  191. }else {
  192. ?>
  193. <table width="600" border="0" cellpadding="0" cellspacing="0">
  194. <tr>
  195. <td height="20"><strong>Artikelen Admin Panel :: KIES ACTIE</strong></td>
  196. </tr>
  197. <tr>
  198. <td height="20" align="center" valign="middle"><a href="admin.php?a=add"><strong>Nieuw
  199. artikel toevoegen?</strong></a></td>
  200. </tr>
  201. <tr>
  202. <td height="20">&nbsp;</td>
  203. </tr>
  204. <?
  205. $arr['select'] = 'SELECT * FROM '.$arr['tnam'];
  206. $arr['getsel'] = mysql_query($arr['select']);
  207. while ($arr['info'] = mysql_fetch_object($arr['getsel'])){
  208. ?>
  209. <tr>
  210. <td height="20"><strong>#
  211. <?
  212. echo $arr['info']->aid;
  213. ?>
  214. :
  215. <?
  216. echo $arr['info']->aname;
  217. ?>
  218. </strong><br>
  219. [ <a href="admin.php?a=delete&id=<? echo $arr['info']->aid; ?>">Verwijderen</a>
  220. | <a href="admin.php?a=edit&id=<? echo $arr['info']->aid; ?>">Bewerken</a>
  221. ]</td>
  222. </tr>
  223. <?
  224. }
  225. ?>
  226. <tr>
  227. <td height="20">&nbsp;</td>
  228. </tr>
  229. </table>
  230. <?
  231. }
  232. ?>


index.php
  1. <?
  2.  
  3. require_once('config.php');
  4.  
  5. if (isset ($_GET['cat'])){
  6.  
  7. if (isset ($_GET['id'])){
  8. if (empty($_GET['id']))
  9. header('location: index.php');
  10. else {
  11. $arr['select'] = 'SELECT * FROM '.$arr['tnam'].' WHERE acat="'.$_GET['cat'].'" AND aid="'.$_GET['id'].'"';
  12. $arr['getsel'] = mysql_query($arr['select']);
  13. $arr['info'] = mysql_fetch_object($arr['getsel']);
  14.  
  15. echo'<table width="600" border="0" cellpadding="0" cellspacing="0">
  16. <tr>
  17. <td height="20" colspan="2">&nbsp;</td>
  18. </tr>
  19. <tr>
  20. <td height="20" colspan="2"><strong>Auteur: </strong></td>
  21. </tr>
  22. <tr>
  23. <td height="20" colspan="2">'.$arr['info']->aauthor.'</td>
  24. </tr>
  25. <tr>
  26. <td height="20" colspan="2"><strong>Artikel naam:</strong></td>
  27. </tr>
  28. <tr>
  29. <td height="20" colspan="2">'.$arr['info']->aname.'</td>
  30. </tr>
  31. <tr>
  32. <td height="20" colspan="2"><strong>Artikel categorie:</strong></td>
  33. </tr>
  34. <tr>
  35. <td height="20" colspan="2">'.$arr['info']->acat.'</td>
  36. </tr>
  37. <tr>
  38. <td height="20" colspan="2"><strong>Artikel commentaar:</strong></td>
  39. </tr>
  40. <tr>
  41. <td height="20" colspan="2">'.$arr['info']->acomment.'</td>
  42. </tr>
  43. <tr>
  44. <td height="20" colspan="2"><strong>Artikel:</strong> (het hele artikel)</td>
  45. </tr>
  46. <tr>
  47. <td height="20" colspan="2">'.simpele_ubb($arr['info']->aartikel).'</td>
  48. </tr>
  49. <tr>
  50. <td height="20" colspan="2">&nbsp;</td>
  51. </tr>
  52. <tr>
  53. <td height="20" colspan="2">&nbsp;</td>
  54. </tr>
  55. </table>';
  56.  
  57. }
  58.  
  59. }else {
  60. if (empty($_GET['cat']))
  61. header('location: index.php');
  62.  
  63.  
  64. $arr['select'] = 'SELECT * FROM '.$arr['tnam'].' WHERE acat="'.$_GET['cat'].'"';
  65. $arr['getsel'] = mysql_query($arr['select']);
  66. while ($arr['info'] = mysql_fetch_object($arr['getsel'])){
  67. ?>
  68.  
  69. <table width="600" border="0" cellspacing="0" cellpadding="0">
  70. <tr>
  71. <td><strong>Categorie:</strong></td>
  72. <td><strong>Auteur:</strong></td>
  73. <tr>
  74. <td><a href="index.php?cat=<? echo $arr['info']->acat; ?>&id=<? echo $arr['info']->aid; ?>"><? echo $arr['info']->aname; ?></a></td>
  75. <td><? echo $arr['info']->aauthor; ?></td>
  76. <tr>
  77. <td colspan="4">&nbsp;</td>
  78. </tr>
  79. </table>
  80.  
  81. <?
  82. }
  83. }
  84. }else{
  85. $arr['select'] = 'SELECT * FROM '.$arr['tnam'];
  86. $arr['getsel'] = mysql_query($arr['select']);
  87. $arr['info'] = mysql_fetch_object($arr['getsel'])
  88.  
  89. ?>
  90. <table width="600" border="0" cellspacing="0" cellpadding="0">
  91. <tr>
  92. <td><strong>Categorie:</strong></td>
  93. <td><strong>Aantal:</strong></td>
  94. </tr>
  95. <?
  96. foreach ($arr['arra'] as $val) {
  97. ?>
  98. <tr>
  99. <td width="79%"><a href="index.php?cat=<? echo $val; ?>"><? echo $val; ?></a></td>
  100. <td width="21%">
  101. <?
  102. $query = mysql_query('SELECT * FROM '.$arr['tnam'].' WHERE acat="'.$val.'"');
  103. $arr['count'] = mysql_num_rows($array);
  104. echo $arr['count'];
  105. ?>
  106. </td>
  107. </tr>
  108. <?
  109. }
  110. ?>
  111. <tr>
  112. <td colspan="4">&nbsp;</td>
  113. </tr>
  114. </table>
  115. <?
  116.  
  117. }
  118. ?>


Enjoy Download code! Download code (.txt)

 Stemmen
Niet ingelogd.

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