Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <head>
  4.  
  5. <script src="tinymce/tinymce.min.js"></script>
  6. <script>tinymce.init({ selector:'textarea' });</script>
  7. <meta charset="utf-8">
  8. </head>
  9.  
  10. <body>
  11. <form name="f1" method="post">
  12. <textarea name="textbox">
  13. </textarea><br>
  14. <input type="submit" value="Dodaj" name="przycisk">
  15. <br/>
  16. </form>
  17.  
  18.  
  19. <?php
  20.  
  21. $polaczenie = mysqli_connect("localhost","root","","4etcms");
  22.  
  23. if( !$polaczenie )
  24. {
  25. echo "Brak polaczenia!";
  26. exit;
  27. }
  28.  
  29. if(isset($_POST['usuwanie']))
  30. {
  31. $id_usuwanie = $_POST['usuwanie'];
  32. $zapyt_usuw = "delete from artykuly where id_artykuly=$id_usuwanie";
  33. $wynik_usuw = mysqli_query($polaczenie,$zapyt_usuw);
  34.  
  35. if($wynik_usuw)
  36. echo "Usunięto!"."<br>";
  37. else
  38. echo "Błąd usuwania!";
  39.  
  40.  
  41. }
  42.  
  43. if(isset($_POST['edycja']))
  44. {
  45. $id_edycja = $_POST['edycja'];
  46. $zapyt_edycja= "select * from artykuly where id_artykuly=$id_edycja";
  47. $wynik_edycja = mysqli_query($polaczenie,$zapyt_edycja);
  48.  
  49. if($wynik_edycja)
  50. {
  51.  
  52. $wiersz = mysqli_fetch_assoc($wynik_edycja);
  53. echo '
  54. <form name="edycja_artykulu" method="post">
  55. <input type="text" name="tytul" value="'.$wiersz['tytul'].'">
  56. <textarea name="tresc">'.$wiersz['tresc'].'</textarea><br>
  57. <input type="hidden" name="id_artykulu" value="'.$wiersz['id_artykuly'].'">
  58. <input type="submit" value="Zapisz zmiany">
  59.  
  60. </form>
  61. ';
  62.  
  63. }
  64.  
  65. }
  66.  
  67.  
  68. if(isset($_POST['tytul']) && isset($_POST['tresc']) && isset($_POST['id_artykulu']) )
  69. {
  70. $tytul = $_POST['tytul'];
  71. $tresc = $_POST['tresc'];
  72. $id_artykulu = $_POST['id_artykulu'];
  73.  
  74. $zap_update = "update artykuly set tytul='$tytul', tresc='$tresc' where id_artykuly=$id_artykulu";
  75. $wyn_update = mysqli_query($polaczenie, $zap_update);
  76. if($wyn_update)
  77. echo "Zmodyfikowano!<br>";
  78. else
  79. echo "Nie zmodyfikowano!<br>";
  80. }
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90. if ( isset($_POST['textbox']) )
  91. {
  92. $tekst = $_POST['textbox'];
  93.  
  94. $zapyt = "insert into artykuly values('','tu bedzie tytul','$tekst')";
  95.  
  96. $wyn = mysqli_query($polaczenie,$zapyt);
  97.  
  98. if($wyn)
  99. {
  100. echo "Dodano!";
  101. }
  102. else
  103. {
  104. echo "Błąd podczas dodawania!";
  105. }
  106.  
  107. }
  108.  
  109.  
  110. // wyswietlanie informacji z bazy danych
  111.  
  112. $zapytanie = "select * from artykuly";
  113.  
  114. $wynik = mysqli_query($polaczenie, $zapytanie);
  115.  
  116. if ($wynik)
  117. {
  118. while( $wiersz = mysqli_fetch_assoc($wynik) )
  119. {
  120.  
  121. $artykul = $wiersz['tytul'];
  122.  
  123. $artykul .= ' <form name="edycja'.$wiersz['id_artykuly'].'" method="post" style="display: inline-block;">
  124. <input type="hidden" name="edycja" value="'.$wiersz['id_artykuly'].'">
  125. <input type="submit" value="Edytuj">
  126. </form> ';
  127.  
  128. $artykul .= ' <form name="usuwanie'.$wiersz['id_artykuly'].'" method="post" style="display: inline-block;">
  129. <input type="hidden" name="usuwanie" value="'.$wiersz['id_artykuly'].'">
  130. <input type="submit" value="Usuń">
  131. </form><br> ';
  132.  
  133.  
  134.  
  135. echo $artykul;
  136.  
  137. }
  138. }
  139. else
  140. {
  141. echo "Bledne zapytanie";
  142. }
  143.  
  144.  
  145.  
  146.  
  147. ?>
  148.  
  149. </body>
  150. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement