SHARE
TWEET

Untitled

a guest Feb 16th, 2020 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. require 'includes/config.php';
  3.  
  4. if ($user->check()) {
  5. ?>
  6. <?php
  7.  
  8.  
  9. if ($user->check()) { // Tylko dla użytkowników zalogowanych
  10.  
  11. ?>
  12.  
  13.  
  14.  
  15. <?php include 'config.php'; ?>
  16. <!DOCTYPE html>
  17. <html lang="pl">
  18.  
  19. <head>
  20.     <title>Kategorie</title>
  21.     <?php include 'meta.php'; ?>
  22. </head>
  23.  
  24. <body id="page-top">
  25.     <nav class="navbar navbar-expand navbar-dark bg-dark static-top">
  26.         <button class="btn btn-link btn-sm text-white order-1 order-sm-0" id="sidebarToggle" href="#">
  27.             <i class="fas fa-bars"></i>
  28.         </button>
  29.         <span class="navbar-brand mr-1">Panel</span>
  30.     </nav>
  31.  
  32.     <div id="wrapper">
  33.  
  34.         <?php include 'sidebar.php'; ?>
  35.  
  36.         <div id="content-wrapper">
  37.  
  38.             <div class="container-fluid">
  39.  
  40.                 <!-- Breadcrumbs-->
  41.                 <h2>Edycja</h2>
  42.                 <br>
  43.  
  44.  
  45.                 <?php
  46. //edytuj nazwe
  47.  
  48. if (isset($_POST['edytujnazwe'])) {
  49. $idd= $_POST['id'];
  50. $stmt = $dbh->prepare("SELECT * FROM zdjecia WHERE id='$idd'");
  51. $stmt->execute();
  52. foreach($stmt as $row)
  53. {
  54. echo '<form action="editphoto.php" method="post">';
  55. echo 'Nazwa: <input type="text" name="nazwa" value="'.$row['nazwa'].'" required />';
  56. echo '<input type="hidden" name="id" value="'.$row['id'].'" />';
  57. echo '<br><br><input class="btn btn-success" type="submit" name="edytujnazwe2" value="Zapisz"/></form>';
  58. }
  59. }
  60. if (isset($_POST['edytujnazwe2'])) {
  61. $nowa = $_POST['nazwa'];
  62. $id= $_POST['id'];
  63. $stmt = $dbh->prepare("UPDATE zdjecia SET nazwa='$nowa' WHERE id='$id'");
  64. $stmt->execute();
  65. header('Location: /admin/zdjecia.php');
  66. }
  67.  
  68. //edytuj nazwe koniec
  69.  
  70. //edytuj zdjecie
  71.  
  72. if (isset($_POST['edytujzdjecie'])) {
  73. $idd= $_POST['id'];
  74. $stmt = $dbh->prepare("SELECT * FROM zdjecia WHERE id='$idd'");
  75. $stmt->execute();
  76. foreach($stmt as $row)
  77. {
  78. echo '<form enctype="multipart/form-data" action="editphoto.php" method="post">';
  79. echo 'Wybierz zdjęcie: <input type="file" name="uploaded_file" required >';
  80. echo '<input type="hidden" name="id" value="'.$row['id'].'" />';
  81. echo '<br><br><input class="btn btn-success" type="submit" name="edytujzdjecie2" value="Zapisz"/></form>';
  82. }
  83. }
  84.  
  85.  
  86. if(isset($_POST['edytujzdjecie2']))
  87. {
  88.     $path = "zdjecia/";
  89.     $random1 = substr(number_format(time() * rand(),0,'',''),0,10);
  90.     $losowa = $random1 . basename( $_FILES['uploaded_file']['name']);
  91.     $path = $path . $losowa ;
  92.     if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $path)) {
  93.       header('Location: /admin/zdjecia.php');
  94.     } else{
  95.         echo "There was an error uploading the file, please try again!";
  96.     }
  97.  
  98. $nazwazdj =  $losowa;
  99.  
  100.  
  101.  
  102. $id= $_POST['id'];
  103. $stmt = $dbh->prepare("UPDATE zdjecia SET zdjecie='$nazwazdj' WHERE id='$id'");
  104. $stmt->execute();
  105. header('Location: /admin/zdjecia.php');
  106. }
  107.  
  108. //edytuj zdjecie koniec
  109.  
  110. //usun zdjecie
  111.  
  112. if (isset($_POST['usunzdjecie'])) {
  113. $idd= $_POST['id'];
  114. $stmt = $dbh->prepare("DELETE FROM zdjecia WHERE id='$idd'");
  115. $stmt->execute();
  116. header('Location: /admin/zdjecia.php');
  117. }
  118.  
  119. //usun zdjecie koniec
  120.  
  121. //edytuj kategorie zdjecia
  122.  
  123.    
  124. if (isset($_POST['kategoriazdjecia'])) {
  125. $idd= $_POST['id'];
  126. $stmt = $dbh->prepare("SELECT * FROM zdjecia WHERE id='$idd'");
  127. $stmt->execute();
  128. foreach($stmt as $row)
  129. {
  130. echo '<form action="editphoto.php" method="post">';
  131. echo "Wybierz kategorie: <select id='kategoria' name='kategoria'>";
  132.  
  133. $stmt2 = $dbh->prepare('SELECT * FROM kategorie');
  134. $stmt2->execute();
  135. foreach($stmt2 as $row2)
  136. {
  137.    
  138.        echo " <option value='".$row2['nazwa']."'>".$row2['nazwa']."</option>";
  139. }
  140.     echo "</select>";
  141. echo '<input type="hidden" name="id" value="'.$row['id'].'" />';
  142. echo '<br><br><input class="btn btn-success" type="submit" name="kategoriazdjecia2" value="Zapisz"/></form>';
  143. }
  144. }
  145. if (isset($_POST['kategoriazdjecia2'])) {
  146. $nowa = $_POST['kategoria'];
  147. $id= $_POST['id'];
  148. $stmt = $dbh->prepare("UPDATE zdjecia SET kategoria='$nowa' WHERE id='$id'");
  149. $stmt->execute();
  150. header('Location: /admin/zdjecia.php');
  151. }
  152.  
  153. //edytuj kategorie zdjecia koniec
  154. ?>
  155.  
  156.  
  157.             </div>
  158.             <!-- /.container-fluid -->
  159.             <?php include 'footer.php'; ?>
  160. </body>
  161.  
  162. </html>
  163. <?php
  164. } else {
  165.     header('Location: /admin/login.php');
  166. echo 'dupa';
  167. }
  168. ?>
  169. <?php
  170. } else {
  171.     header('Location: /admin/login.php');
  172. echo 'dupa';
  173. }
  174. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top