Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- if (!isset($_SESSION['username']) || empty($_SESSION['username'])) {
- header('location: AdminPanel.php');
- exit();
- return;
- }
- $table = $_POST['tablename'];
- $hersteller = $_POST['Hersteller'];
- $hersteller = split("ID: ", $hersteller)[1];
- $hersteller = (int) str_replace(")", "", $hersteller);
- $servername = "localhost";
- $username = "pvpultimate_fb";
- $password = "123456789";
- $database = "pvpultimate_fb";
- include_once("DatabaseManager.php");
- $dbManager = new DatabaseManager;
- $dbManager::setURL($servername);
- $dbManager::setUsername($username);
- $dbManager::setPassword($password);
- $dbManager::setDatabaseName($database);
- $dbManager::connect();
- $insert = "INSERT INTO $table (";
- foreach( $_POST as $key => $value ) {
- if($key == "tablename") continue;
- if($key == "Submit") continue;
- if($key == "Kategorien") continue;
- if($key == "Hersteller") continue;
- $insert .= $key;
- $insert .= ", ";
- }
- $insert .= "HID";
- $insert .= ", ";
- $insert = substr($insert, 0, strlen($insert)-2);
- $insert .= ") VALUES (";
- foreach( $_POST as $key => $value ) {
- if($key == "tablename") continue;
- if($key == "Submit") continue;
- if($key == "Kategorien") continue;
- if($key == "Hersteller") continue;
- $insert .= "'" . $value . "'";
- $insert .= ", ";
- }
- $insert .= "'" . $hersteller . "'";
- $insert .= ", ";
- $insert = substr($insert, 0, strlen($insert)-2);
- $insert .= ");";
- $success = $dbManager::query($insert);
- $getID = "SELECT PID FROM Produkt WHERE PURL='" . $_POST["PURL"] . "'";
- $res = $dbManager::query($getID);
- $pID;
- if($row=mysql_fetch_array($res)){
- $pID = $row['PID'];
- }
- if(isset($_POST['Kategorien']) && !empty($_POST['Kategorien'])){
- foreach ($_POST['Kategorien'] as $value) {
- $s = "INSERT INTO ist_in(PID, KID) VALUES($pID, $value)";
- $dbManager::query($s);
- }
- }
- if($success){
- ?>
- <script type="text/javascript" id="runscript">
- var name = "<?php echo $_POST['PName']; ?>";
- swal("Produkt hinzugefügt", name, "success");
- </script>
- <?php
- } else {
- ?>
- <script type="text/javascript" id="runscript">
- var name = "<?php echo $_POST['PName']; ?>";
- swal(":(", "Produkt konnte nicht hinzugefügt werden", "error");
- </script>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement