Formular mit mehrfachen Submit-Input + Übergabe als Variable

Hallo Freunde der Webprogrammierung :smiley:

Ich hab hier ein Problem mit einem etwas anderem Formular zum bearbeiten eines Galerie-Eintrages.
Und zwar will ich mehrere ‘Submit-Button’ in einem Form verwenden um Bilder einzeln zu aktualisieren.
Damit versuche ich Code zu sparen, in meiner Theorie sollte das auch funktionieren, in der Praxis aber liegen viele herausgerupfte Haarbüschel um mich herum.

Zur Kontrolle verwende ich echo $new_image;, leider wird mir diese Variable nie angezeigt.

Ich sehe nach unzähligen Versuchen den Baum vor lauter Wald nicht und hoffe dass mir jemand den entscheidenden Tipp geben kann :wink:

PS: Ich bin mir nicht mehr sicher ob es ein HTML- oder PHP-Problem ist, deswegen fange ich hier an…bei Bedarf einfach verschieben, Danke!
(Dieses Skript steckt übrigens in den Kinderschuhen, also nicht wundern wegen Formatierung usw. :hammer: )

<div id="content-main">
    <div id="content-head">
        Galerie-Eintrag bearbeiten
    </div>
    <div id="content-body">
        <?php
        $gid = $_GET;
        $gid = $gid['gid'];
        if(isset($_POST["save_info"]))
        {
            require("mysql/db_connect.inc.php");
            $statement = $db->prepare("UPDATE bl_galerie SET
                                                            name = :name_neu,
                                                            date = :date_neu,
                                                            info = :info_neu,
                                                            place = :place_neu
                                      WHERE id = '$gid'");
            $statement->execute(array(
                                     'name_neu' => $_POST['edit_name'],
                                     'date_neu' => $_POST['edit_date'],
                                     'info_neu' => $_POST['edit_info'],
                                     'place_neu' => $_POST['edit_place']
                                ));
            echo "<p>Eintrag erfolgreich geändert!</p>";
        }
        if(isset($_POST["edit_image"]))
        {
            if(isset($_POST['new_image_01'])) {$new_image = "image_01";}
            elseif(isset($_POST['new_image_02'])) {$new_image = "image_02";}
            elseif(isset($_POST['new_image_03'])) {$new_image = "image_03";}
            elseif(isset($_POST['new_image_04'])) {$new_image = "image_04";}
            elseif(isset($_POST['new_image_05'])) {$new_image = "image_05";}
            elseif(isset($_POST['new_image_06'])) {$new_image = "image_06";}
            elseif(isset($_POST['new_image_07'])) {$new_image = "image_07";}
            elseif(isset($_POST['new_image_08'])) {$new_image = "image_08";}
            elseif(isset($_POST['new_image_09'])) {$new_image = "image_09";}
            elseif(isset($_POST['new_image_10'])) {$new_image = "image_10";}
            echo $new_image;
        }
        if(isset($_POST["delete_image"]))
        {

        }


        require("./mysql/db_connect.inc.php");
        $statement = $db->query("SELECT * FROM bl_galerie WHERE id = '$gid'");
        while  ($db_gallery = $statement->fetch()):
            $db_name = $db_gallery['name'];
            $db_date = $db_gallery['date'];
            $db_info = $db_gallery['info'];
            $db_place = $db_gallery['place'];
            $db_image_01 = $db_gallery['image_01'];
            $db_image_02 = $db_gallery['image_02'];
            $db_image_03 = $db_gallery['image_03'];
            $db_image_04 = $db_gallery['image_04'];
            $db_image_05 = $db_gallery['image_05'];
            $db_image_06 = $db_gallery['image_06'];
            $db_image_07 = $db_gallery['image_07'];
            $db_image_08 = $db_gallery['image_08'];
            $db_image_09 = $db_gallery['image_09'];
            $db_image_10 = $db_gallery['image_10'];
        endwhile;
        ?>
        <form action="admin.php?loc=admin_gallery_edit&gid=<?php echo $gid; ?>" method="post">
            Name: <br /><input type="text" name="edit_name" size="30" value="<?php echo $db_name; ?>">
            <br /><br />
            Datum: <br /><input type="text" name="edit_date" size="30" value="<?php echo $db_date; ?>">
            <br /><br />
            Ort: <br /><input type="text" name="edit_place" size="30" value="<?php echo $db_place; ?>">
            <br /><br />
            Info: <br /><textarea rows="8" name="edit_info"><?php echo $db_info; ?></textarea>
            <br /><br />
            <input type="Submit" name="save_info" value="Speichern">
        </form>
        <br /><br />
        <form name="edit_image" enctype="multipart/form-data" action="admin.php?loc=admin_gallery_edit&gid=<?php echo $gid; ?>" method="post">
        <table align="center" border="0" width="626">
            <tr>
                <td><img width="313" height="125" src="./images/galerie/<?php echo $db_image_01; ?>" alt="Bild 01"><br /><input type="file" name="new_image" size="60" maxlength="255"><input type="Submit" name="new_image_01" value="Speichern"><br /><input type="Submit" name="delete_image" id="201" value="Löschen"><br /><br /></td>
                <td><img width="313" height="125" src="./images/galerie/<?php echo $db_image_02; ?>" alt="Bild 02"><br /><input type="file" name="new_image" size="60" maxlength="255"><input type="Submit" name="new_image_02" value="Speichern"><br /><input type="Submit" name="delete_image" id="202" value="Löschen"><br /><br /></td>
            </tr>
            <tr>
                <td><img width="313" height="125" src="./images/galerie/<?php echo $db_image_03; ?>" alt="Bild 03"><br /><input type="file" name="new_image" size="60" maxlength="255"><input type="Submit" name="new_image_03" value="Speichern"><br /><input type="Submit" name="delete_image" id="203" value="Löschen"><br /><br /></td>
                <td><img width="313" height="125" src="./images/galerie/<?php echo $db_image_04; ?>" alt="Bild 04"><br /><input type="file" name="new_image" size="60" maxlength="255"><input type="Submit" name="new_image_04" value="Speichern"><br /><input type="Submit" name="delete_image" id="204" value="Löschen"><br /><br /></td>
            </tr>
            <tr>
                <td><img width="313" height="125" src="./images/galerie/<?php echo $db_image_05; ?>" alt="Bild 05"><br /><input type="file" name="new_image" size="60" maxlength="255"><input type="Submit" name="new_image_05" value="Speichern"><br /><input type="Submit" name="delete_image" id="205" value="Löschen"><br /><br /></td>
                <td><img width="313" height="125" src="./images/galerie/<?php echo $db_image_06; ?>" alt="Bild 06"><br /><input type="file" name="new_image" size="60" maxlength="255"><input type="Submit" name="new_image_06" value="Speichern"><br /><input type="Submit" name="delete_image" id="206" value="Löschen"><br /><br /></td>
            </tr>
            <tr>
                <td><img width="313" height="125" src="./images/galerie/<?php echo $db_image_07; ?>" alt="Bild 07"><br /><input type="file" name="new_image" size="60" maxlength="255"><input type="Submit" name="new_image_07" value="Speichern"><br /><input type="Submit" name="delete_image" id="207" value="Löschen"><br /><br /></td>
                <td><img width="313" height="125" src="./images/galerie/<?php echo $db_image_08; ?>" alt="Bild 08"><br /><input type="file" name="new_image" size="60" maxlength="255"><input type="Submit" name="new_image_08" value="Speichern"><br /><input type="Submit" name="delete_image" id="208" value="Löschen"><br /><br /></td>
            </tr>
            <tr>
                <td><img width="313" height="125" src="./images/galerie/<?php echo $db_image_09; ?>" alt="Bild 09"><br /><input type="file" name="new_image" size="60" maxlength="255"><input type="Submit" name="new_image_09" value="Speichern"><br /><input type="Submit" name="delete_image" id="209" value="Löschen"><br /><br /></td>
                <td><img width="313" height="125" src="./images/galerie/<?php echo $db_image_10; ?>" alt="Bild 10"><br /><input type="file" name="new_image" size="60" maxlength="255"><input type="Submit" name="new_image_10" value="Speichern"><br /><input type="Submit" name="delete_image" id="210" value="Löschen"><br /><br /></td>
            </tr>
        </table>
        </form>
    </div>
</div>

Setz mal ans Ende der Ausgabe ein
var_dump($new_image);

Was ist die Ausgabe? Das wäre dann nämlich der Inhalt den die Variabel enthält. Am besten auch das Errorreporting auf E_ALL stellen, und die dort angezeigten Fehler hier eben mit Posten