skoro tak tego pragniesz to masz:
if(!isset($_GET['action'])){ if($_GET['method'] == "remove"){
$id = $_GET['id'];
header("Location: index.php?page=gallery"); } else{
echo '<table border="1"><thead><tr><td>Tytuł</td><td>Opis</td><td>Miniaturka</td><td>Akcja</td></tr></thead><tbody>'; $query = mysql_query("SELECT * FROM `gallery` ORDER BY id DESC"); echo '<tr><td>'.$result['title'].'</td><td>'.$result['comment'].'</td><td><img style="max-width:100px;" src="../graphics/'.$result['miniimg'].'" alt="'.$result['miniimg'].'" /></td><td><a href="index.php?page=gallery&method=remove&id='.$result['id'].'">Usuń</a></td></tr>'; }
}
} else if($_GET['action'] == "add"){
if(!isset($_POST['dodajzdj']) || !isset($_POST['dodaj'])) {
if(isset($_POST['dodajzdj'])) {
if ($_FILES['graphic_big']['error'] > 0 || $_FILES['graphic_small']['error'] > 0) {
echo 'Wystąpił bład podczas dodawania grafiki.<br />'; header( "refresh:5;url=?page=gallery&action=add" ); } else {
if(file_exists("../graphics/".$_FILES['graphic_big']['name'])){ echo 'Plik "'.$_FILES['graphic_big']['name'].'" już istnieje.'; } else {
$from = array('ą','ż','ź','ć','ę','ń','ó','ł'); $to = array('a','z','z','c','e','n','o','l'); $name = str_replace($from, $to, $_FILES['graphic_big']['name']); $name_small = str_replace($from, $to, $_FILES['graphic_small']['name']); $name = $global->no_space($name);
$name_small = $global->no_space($name_small);
echo 'Grafiki została dodana pomyślnie.<br />'; echo '<img src="../graphics/'.$name_small.'" alt="'.$name_small.'" style="max-width:300px;" /><img src="../graphics/'.$name.'" alt="'.$name.'" style="max-width: 300px;" /><br /><form action="?page=gallery&action=add" method="post"> <input type="hidden" name="graphic_big" value="'.$name.'" />
<input type="hidden" name="graphic_min" value="'.$name_small.'" />
Temat: <input type="text" name="title" /><br />
Kategoria: <select name="cat"><option value="other">Inne</option>';
$query = mysql_query("SELECT * FROM cats ORDER BY col"); echo '<option value="'.$result['skrot'].'">'.$result['nazwa'].'</option>'; }
</select><br />
Opis: <textarea cols="100" rows="7" name="opis"></textarea><br />
<input type="submit" name="dodaj" value="Dodaj projekt" />
</form>';
}
}
} else if(isset($_POST['dodaj'])){ $title = $_POST['title'];
$cat = $_POST['cat'];
$comment = $_POST['opis'];
$miniimg = $_POST['graphic_min'];
$maximg = $_POST['graphic_big'];
mysql_query("INSERT INTO gallery(title, cat, comment, miniimg, maximg) VALUES ('$title', '$cat', '$comment', '$miniimg', '$maximg') ") or
die (mysql_error());
echo "Praca została dodana pomyślnie. Teraz nastąpi przekierowanie..."; header("refresh:5;url=index.php?page=gallery"); } else
{
echo '<form action="?page=gallery&action=add" method="post" enctype="multipart/form-data"> Wybierz grafikę do dodania: <input type="file" name="graphic_big"><br />
Wybierz miniaturkę: <input type="file" name="graphic_small"><br />
<input type="submit" name="dodajzdj" value="Dodaj zdjęcie" />
</form>';
}
}
}