Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7989209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:41:22+00:00 2026-06-04T12:41:22+00:00

I made a form in php. I am using 3 different forms in the

  • 0

I made a form in php. I am using 3 different forms in the document. So I have to distinguish these forms. Therefore I am using the submit “name-tag”.

if ('POST' == $_SERVER['REQUEST_METHOD']) {
    if (isset($_POST['submit_1'])) {
        ....
    }
    if (isset($_POST['submit_2'])) {
        ....
    }
    if (isset($_POST['submit_3'])) {
        ....
    }
}

This is how I check these different submit-buttons.

But I noticed that I need to use the click function in JS instead of the submit function (cause the form shouldn’t be submitted with a page-reload)

$('.erzaehlcafe_submit').click(function(){
    if ($('#year_from').val() == 'none' || $('#month_from').val() == 'none' 
            || $('#day_from').val() == 'none' || $('#topic').val() == '' || $('#contributer').val() == '' 
            || $('#begin').val() == '' || $('#place').val() == '' || $('#entrance').val() == '') {
        $("#dialog_empty").dialog( "open" );
        return false;
    }
    var form = $('#erzaehlcafe_add');  
    var data = form.serialize(); 

    $.ajax({
        url: "index.php?section=events",
        type: "POST",
        data: data,
        success: function (reqCode) {
        alert(reqCode);
            if (reqCode == 1) {
                //Date inserted into DB
                $("#dialog_add_event").dialog( "open" );
            } else {
                $("#dialog_add_event_error").dialog( "open" );
            }
        }
    });
    return false; //dont submit form
});

So how to make a difference between these forms? (All of them are using same names for same input).

The only way to solve the problem is to define other name indexes for all input typed. Is there any other way?

Edit: Here is my template ( remember I used submit_1, submit_2 and submit_3 instead of erzaehlcafe_submit and so on to make it more precise)

<div id="event_accordion">
<h3><a href="#">Erzählcafé hinzufügen</a></h3>
<div>
    <form id="erzaehlcafe_add" action="index.php?section=events" method="post" accept-charset="utf-8">
        <table>
            <tr>
                <td>Datum:</td>
                <td>
                    <select name="day_from" id="day_from">
                        <option value="none" class="bold italic">Tag</option>
                            <?php
                                for($i=1; $i<=31; $i++){
                                    echo "<option value=\"".$i."\">".$i."</option>\n";
                                }
                            ?>
                    </select>
                    <select name="month_from" id="month_from">
                        <option value="none" class="bold italic">Monat</option>
                            <?php
                                for($i=1; $i<=12; $i++){
                                    echo "<option value=\"".$i."\">".$month_name[$i]."</option>\n";
                                }
                            ?>
                    </select>
                    <select name="year_from" id="year_from">
                        <option value="none" class="bold italic">Jahr</option>
                            <?php
                                for($i=2008; $i<=$year; $i++){
                                    echo "<option value=\"".$i."\">".$i."</option>\n";
                                }
                            ?>
                    </select>
                </td>
            </tr>
            <tr>
                <td>Thema:</td>
                <td><input type="text" name="topic" id="topic" /></td>
            </tr>
            <tr>
                <td>Referent:</td>
                <td><input type="text" name="contributer" id="contributer" /></td>
            </tr>
            <tr>
                <td>Beginn:</td>
                <td><input type="text" name="begin" id="begin" /> Uhr</td>
            </tr>
            <tr>
                <td>Ort:</td>
                <td><input type="text" name="place" id="place" /></td>
            </tr>
            <tr>
                <td>Eintritt:</td>
                <td><input type="text" name="entrance" id="entrance" /> €</td>
            </tr>
        </table>
        <br />
        <div id="add_erzaehlcafe">
            <input type="submit" id="small" class="erzaehlcafe_submit" name="erzaehlcafe_submit" value="speichern">
        </div>
    </form>
</div>
<h3><a href="#">Vortrag hinzufügen</a></h3>
<div>
    <form name="vortrag_add" action="index.php?section=events" method="post" accept-charset="utf-8">
        <table>
            <tr>
                <td>Datum:</td>
                <td>
                    <select name="day_from">
                        <option value="0" class="bold italic">Tag</option>
                            <?php
                                for($i=1; $i<=31; $i++){
                                    echo "<option value=\"".$i."\">".$i."</option>\n";
                                }
                            ?>
                    </select>
                    <select name="month_from">
                        <option value="0" class="bold italic">Monat</option>
                            <?php
                                for($i=1; $i<=12; $i++){
                                    echo "<option value=\"".$i."\">".$month_name[$i]."</option>\n";
                                }
                            ?>
                    </select>
                    <select name="year_from">
                        <option value="0" class="bold italic">Jahr</option>
                            <?php
                                for($i=2008; $i<=$year; $i++){
                                    echo "<option value=\"".$i."\">".$i."</option>\n";
                                }
                            ?>
                    </select>
                </td>
            </tr>
            <tr>
                <td>Thema:</td>
                <td><input type="text" name="name_topic" id="name_topic" /></td>
            </tr>
            <tr>
                <td>Referent:</td>
                <td><input type="text" name="name_contributer" id="name_contributer" /></td>
            </tr>
            <tr>
                <td>Beginn:</td>
                <td><input type="text" name="name_begin" id="name_begin" /> Uhr</td>
            </tr>
            <tr>
                <td>Ort:</td>
                <td><input type="text" name="name_place" id="name_place" /></td>
            </tr>
            <tr>
                <td>Eintritt:</td>
                <td><input type="text" name="name_entrance" id="name_entrance" /> €</td>
            </tr>
        </table>
        <br />
        <div id="add_vortrag">
            <input type="submit" id="small" class="vortrag_submit" name="vortrag_submit" value="speichern">
        </div>
    </form>
</div>
<h3><a href="#">Ausstellung hinzufügen</a></h3>
<div>
    <form name="ausstellung_add" action="index.php?section=events" method="post" accept-charset="utf-8">
        <table>
            <tr>
                <td>Von:</td>
                <td>
                    <select name="day_from">
                        <option value="0" class="bold italic">Tag</option>
                            <?php
                                for($i=1; $i<=31; $i++){
                                    echo "<option value=\"".$i."\">".$i."</option>\n";
                                }
                            ?>
                    </select>
                    <select name="month_from">
                        <option value="0" class="bold italic">Monat</option>
                            <?php
                                for($i=1; $i<=12; $i++){
                                    echo "<option value=\"".$i."\">".$month_name[$i]."</option>\n";
                                }
                            ?>
                    </select>
                    <select name="year_from">
                        <option value="0" class="bold italic">Jahr</option>
                            <?php
                                for($i=2008; $i<=$year; $i++){
                                    echo "<option value=\"".$i."\">".$i."</option>\n";
                                }
                            ?>
                    </select>
                </td>
            </tr>
            <tr>
                <td>Bis:</td>
                <td>
                    <select name="day_till">
                        <option value="0" class="bold italic">Tag</option>
                            <?php
                                for($i=1; $i<=31; $i++){
                                    echo "<option value=\"".$i."\">".$i."</option>\n";
                                }
                            ?>
                    </select>
                    <select name="month_till">
                        <option value="0" class="bold italic">Monat</option>
                            <?php
                                for($i=1; $i<=12; $i++){
                                    echo "<option value=\"".$i."\">".$month_name[$i]."</option>\n";
                                }
                            ?>
                    </select>
                    <select name="year_till">
                        <option value="0" class="bold italic">Jahr</option>
                            <?php
                                for($i=2008; $i<=$year; $i++){
                                    echo "<option value=\"".$i."\">".$i."</option>\n";
                                }
                            ?>
                    </select>
                </td>
            </tr>
            <tr>
                <td>Thema:</td>
                <td><input type="text" name="name_topic" id="name_topic" /></td>
            </tr>
            <tr>
                <td>Aussteller:</td>
                <td><input type="text" name="name_contributer" id="name_contributer" /></td>
            </tr>
            <tr>
                <td>Eintritt:</td>
                <td><input type="text" name="name_entrance" id="name_entrance" /></td>
            </tr>
        </table>
        <br />
        <div id="add_ausstellung">
            <input type="submit" id="small" class="ausstellung_submit" name="ausstellung_submit" value="speichern">
        </div>
    </form>
</div>
<h3><a href="#">Termine bearbeiten/löschen</a></h3>
<div>
    <button id="edit_event">Termin bearbeiten</button>
</div>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:41:25+00:00Added an answer on June 4, 2026 at 12:41 pm

    Add an <input type="hidden"> to each form with name="submit_X". The input type="submit" element seems to be ignored by serialize();.

    Example:

    <input type="text"​​​​​​​​​​​​ id="year_from" name="year_from" />
    <!-- More inputs.... -->
    <input type="hidden" name="submit_1" value="true" />​​​​​​​​​​​​​​​​​
    

    You could also use JavaScript to add another key to the POST data.

    Take a look at this fiddle: http://jsfiddle.net/cd7Yy/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a form that accepts query and executes it through php. I
i have made a simple php contact form following this tutorial: http://www.catswhocode.com/blog/how-to-create-a-built-in-contact-form-for-your-wordpress-theme The big
In my iOS application I have made a form that should submit data into
I have made a Base Form which is inherited by most Forms in the
I have started using jQuery and rails. I have made a simple form that
I'm using php,html,javascript,mysql. My functionality goes like this. I have a division made in
Good day! I am a newbie in php.. I made a form using html
I have made something just like this using php and mysql. Just curious to
I have to post to a URL using PHP. right now it works but
I have made a simple web form in Google app engine where I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.