Advertisement
Guest User

Untitled

a guest
Mar 11th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4. if (!isset($_SESSION['username']) || empty($_SESSION['username'])) {
  5. header('location: AdminPanel.php');
  6. exit();
  7. return;
  8. }
  9.  
  10. $table = $_POST['tablename'];
  11.  
  12. $hersteller = $_POST['Hersteller'];
  13. $hersteller = split("ID: ", $hersteller)[1];
  14. $hersteller = (int) str_replace(")", "", $hersteller);
  15.  
  16. $servername = "localhost";
  17. $username = "pvpultimate_fb";
  18. $password = "123456789";
  19. $database = "pvpultimate_fb";
  20.  
  21. include_once("DatabaseManager.php");
  22.  
  23. $dbManager = new DatabaseManager;
  24.  
  25. $dbManager::setURL($servername);
  26. $dbManager::setUsername($username);
  27. $dbManager::setPassword($password);
  28. $dbManager::setDatabaseName($database);
  29.  
  30. $dbManager::connect();
  31.  
  32. $insert = "INSERT INTO $table (";
  33.  
  34. foreach( $_POST as $key => $value ) {
  35. if($key == "tablename") continue;
  36. if($key == "Submit") continue;
  37. if($key == "Kategorien") continue;
  38. if($key == "Hersteller") continue;
  39. $insert .= $key;
  40. $insert .= ", ";
  41. }
  42. $insert .= "HID";
  43. $insert .= ", ";
  44.  
  45. $insert = substr($insert, 0, strlen($insert)-2);
  46. $insert .= ") VALUES (";
  47.  
  48. foreach( $_POST as $key => $value ) {
  49. if($key == "tablename") continue;
  50. if($key == "Submit") continue;
  51. if($key == "Kategorien") continue;
  52. if($key == "Hersteller") continue;
  53. $insert .= "'" . $value . "'";
  54. $insert .= ", ";
  55. }
  56. $insert .= "'" . $hersteller . "'";
  57. $insert .= ", ";
  58.  
  59. $insert = substr($insert, 0, strlen($insert)-2);
  60. $insert .= ");";
  61.  
  62. $success = $dbManager::query($insert);
  63.  
  64. $getID = "SELECT PID FROM Produkt WHERE PURL='" . $_POST["PURL"] . "'";
  65.  
  66. $res = $dbManager::query($getID);
  67. $pID;
  68. if($row=mysql_fetch_array($res)){
  69. $pID = $row['PID'];
  70. }
  71.  
  72. if(isset($_POST['Kategorien']) && !empty($_POST['Kategorien'])){
  73. foreach ($_POST['Kategorien'] as $value) {
  74. $s = "INSERT INTO ist_in(PID, KID) VALUES($pID, $value)";
  75. $dbManager::query($s);
  76. }
  77. }
  78.  
  79. if($success){
  80. ?>
  81. <script type="text/javascript" id="runscript">
  82. var name = "<?php echo $_POST['PName']; ?>";
  83. swal("Produkt hinzugefügt", name, "success");
  84. </script>
  85. <?php
  86. } else {
  87. ?>
  88. <script type="text/javascript" id="runscript">
  89. var name = "<?php echo $_POST['PName']; ?>";
  90. swal(":(", "Produkt konnte nicht hinzugefügt werden", "error");
  91. </script>
  92. <?php
  93. }
  94.  
  95. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement