Submitting 2 Forms with 1 Button or 1 Input

20
March 15, 2019, at 9:20 PM

currently i have 2 Buttons (well 1 Button and 1 Input with a Bootstrap button class) I use to upload a picture, and add a text to that picutre.

Ofcourse thats not a good way to handle it, and i would like to merge these 2 buttons into 1.

First uploading the picture (triggering the dropzone script) and then adding the Text from a form to a SQL Database.

I have to idea if its even possible to combine that into one.

I have my code shown below.

<!-- PICTURE UPLOAD USING DROPZONE -->
<form action="upload/doupload.php" class="dropzone" id="datenhochlad" ></form>

<!-- FORM TABLE TO INPUT TEXT WHICH SHALL BE SENT TO SQL  -->
        <form method="post" id="texteingabetabelle">
            <div>
            <table class="table table-bordered">
                <tbody>
                    <tr>
                        <td>Text zum Bild:</td>
                        <td>
                            <input class="eingabe" type="text" name="bildtext" width="100px" />
                        </td>
                    </tr>
                    <tr>
                        <td>Bild ID:  <?php echo $bildid+1 ?></td>
                    </tr>

                </tbody>
            </table>
</div>
<!-- BUTTON TO EXECUTE DROPZONE -> UPLOADING THE PICTURE -->
        <center><button type="submit" id="hochladdaten" class="btn btn-primary">Bild Hochladen</button><center>
<br>
<!-- BUTTON TO EXECUTE THE SQL QUERY  -->
    <input type="submit" class="btn btn-success" id="hochladdaten" name="hochladdaten" value="Text Senden" />
        </form>


            <!-- SQL STUFF -->
            <?php
    if(isset($_POST['hochladdaten']))
        {
            $bildtext = $_POST['bildtext'];
                sleep(5);
            $omadbconnect->query("insert into bildertexte(text,bildid) values('$bildtext', '$bildid' )");
            sleep(1);
            header('Location: index.php');
        if(!$omadbconnect) 
        { echo mysqli_error();
         }
    else
    {
    }
         }  
    ?>
READ ALSO
How to optimize a mysql query

How to optimize a mysql query

I have a problem with a mysql query that sometimes needs more than 80 secs to execute

54
Angular 7 : Cannot add or update a child row: a foreign key constraint fails

Angular 7 : Cannot add or update a child row: a foreign key constraint fails

I am stuck on this SQL error and I do not understand why:

47
&ldquo;Writing configuration file failed&rdquo; in MySQL Server 8.0.15

“Writing configuration file failed” in MySQL Server 8.0.15

While set up the configuration in MySQL Server 80

33