Public paste
fout in id ophalen
By: pages.php | Date: Mar 8 2010 13:32 | Format: PHP | Expires: never | Size: 2.64 KB | Hits: 689

  1. <?php
  2. include("db.php");
  3. include("content_functions.php");
  4.  
  5. //variabelen declareren en content ophalen
  6. $a = $_GET["a"];
  7. $id = $_GET["id"];
  8. $idr = $_GET["idr"];
  9. $idb = $_GET["idb"];
  10.  
  11. //content ophalen met controle menu links, items boven of items rechts. Items rechts is $idr, items boven is $idb menu links is $id
  12. if($idr == ""){
  13. $sql = "SELECT * FROM contents where id='".$_GET["id"]."'";
  14. $result = mysql_query($sql) or die("Query failed : " . mysql_error());
  15. $row = mysql_fetch_assoc($result);
  16. $content = $row['content'];
  17. $title = $row['title'];
  18. //controleren of de gebruiker is ingelogd
  19. if(session_is_registered("myusername")){
  20. $insert = "<a href='index.php?id=$id&a=insert'>Nieuwe pagina</a>";
  21. $delete = '<a href="index.php?id=' . $id . '&a=delete" onclick="return confirm('Weet u zeker dat deze pagina verwijderd mag worden?')">Verwijder deze pagina</a>';
  22. $aanpassen = "<a href='index.php?id=$id&a=edit'>Aanpassen</a>";
  23. }else{
  24. $delete = "";
  25. $aanpassen = "";
  26. $insert = "";
  27.  
  28. }//als menu rechts wordt geklikt
  29. }elseif($id == ""){
  30. $sql = "SELECT * FROM content_rechts where idr='".$_GET["idr"]."'";
  31. $result = mysql_query($sql) or die("Query failed : " . mysql_error());
  32. $row = mysql_fetch_assoc($result);
  33. $content = $row['content'];
  34. $title = $row['title'];
  35. //controleren of de gebruiker is ingelogd
  36. if(session_is_registered("myusername")){
  37. $aanpassen = "<a href='index.php?idr=$idr&a=edit'>Aanpassen</a>";
  38. }else{
  39. $delete = "";
  40. $aanpassen = "";
  41. $insert = "";
  42.  
  43. //menu boven
  44. }}elseif($id and $idr == ""){
  45. $sql = "SELECT * FROM content_boven where idb='".$_GET["idb"]."'";
  46. $result = mysql_query($sql) or die("Query failed : " . mysql_error());
  47. $row = mysql_fetch_assoc($result);
  48. $content = $row['content'];
  49. $title = $row['title'];
  50. //controleren of de gebruiker is ingelogd
  51. if(session_is_registered("myusername")){
  52. $aanpassen = "<a href='index.php?idb=$idb&a=edit'>Aanpassen</a>";
  53. }else{
  54. $delete = "";
  55. $aanpassen = "";
  56. $insert = "";
  57. }}
  58.  
  59.  
  60. if ($_GET["a"] == "" or $_GET["a"] == "edit" or $_GET["a"] == "delete" or $_GET["a"] == "insert"){
  61. //inhoud tabel maken
  62. echo "<table align='center' width='705' border='0'>
  63. <tr>
  64. <th align='center'>$title</th>
  65. </tr>";
  66. echo "<tr>";   
  67. echo "<td align='center'>" . $aanpassen . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"  . $delete . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"  . $insert . "</td>";
  68. echo "</tr>";
  69. echo "<tr>";
  70. echo "<td>" . $content  . "</td>";
  71. echo "</tr>";
  72. echo "</table>";
  73. echo "<br>";
  74. }
  75. //functies aanroepen
  76. if ($_GET["a"] == "edit"){
  77. edit($content, $a, $id, $idr);
  78. }else if ($_GET["a"] == "delete"){
  79. delete($content, $a, $id);
  80. }else if ($_GET["a"] == "insert"){
  81. insert($content, $a, $id);
  82. }
  83. ?>