<?php require_once 'pictures.php'; require_once 'config.php'; session_start(); if ($_SESSION['admin'] == true && isset($_POST['p_submit'])) { if ($_FILES['p']['error'] == 0 && $_FILES['p']['type'] == 'image/jpeg') { $pic = new Pictures($servername, $dbusername, $dbpass, $dbname); $temp = explode(".", $_FILES["p"]["name"]); $extension = end($temp); if (is_uploaded_file($_FILES['p']['tmp_name'])) { $id = intval($pic->getPictureID()); $id++; if (!move_uploaded_file($_FILES['p']['tmp_name'], $path . $id . '.' . $extension)) { echo '<h2>Błąd</h2>'; header("Refresh: 3; URL=http://" . $_SERVER['SERVER_NAME'] . "/adminPanel.php"); return false; } else { $pic->addPicture($_POST['p_name'], $_POST['p_price'], $_POST['p_tech'], $_POST['p_type'], $_POST['p_sizes'], $_POST['p_color'], $_POST['p_info']); } } } } Header("Location:../adminPanel.php?added=true");