Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • Last Modified:

submit button submits two forms

Hi,
I have a page with two forms in it.
On the second form it has 2 submit buttons.
When I click on one of the second forms submit, it submits the first form as well.
What am I doing wrong?
Thanks
Orly


      <form name="readexcel" action="/test//new_group_wizard.php?page=add_contacts" method="post" enctype="multipart/form-data" accept-charset="utf-8" >

      

      <div align="right"><h4><a href="docs/excel_files/contact_list.xls">¿¿¿¿ ¿¿¿¿¿ </a> ¿¿ ¿¿¿¿¿ ¿¿¿¿ ¿¿¿¿¿</h4>

<p>.¿¿¿¿ ¿¿ ¿¿¿¿¿¿ ¿¿¿¿¿ ¿¿ ¿¿¿¿¿ ¿¿¿¿ ¿¿¿¿¿ ¿¿¿¿¿¿ ¿¿¿¿¿ ¿¿¿¿</p>

<p>¿¿¿¿¿ ¿¿¿¿¿? ¿¿¿¿ ¿¿¿¿ ¿¿ ¿¿¿ ¿¿¿¿¿ ¿"¿¿¿ ¿¿¿¿" <br><br></p></div>

      <div>

<label for="excel_fl">¿¿¿ ¿¿¿¿:</label> <input type="file" id="excel_fl" name="excel_fl">

      </div>

      <div style="clear:both" ><br><input type="submit" id="excel" value="¿¿¿¿ ¿¿¿¿¿"/></div>      

      </fieldset>

            

      

      <input type="hidden" name="submitted" value="TRUE" >

      </form>

      

 </div>
 <div id="manual" width="100%">

      <form name="contact_form" id="con_form" action="/test//new_group_wizard.php?page=add_contacts" method="post" enctype="multipart/form-data" accept-charset="utf-8" >
            <input type="hidden" name="submitted" value="TRUE" />


            <input type="hidden" name="add_more" value="FALSE" />
            

             <fieldset class="login">
                  <input type="hidden" id="con_ind" name="con_ind" value=""/>
                  <input type="hidden" id="motherID" name="motherID" value=""/>
                  <input type="hidden" id="fatherID" name="fatherID" value=""/>
                  
                  <legend>¿¿¿¿ ¿¿¿¿</legend>
                  <div>
                        <label for="childName">¿¿:</label> <input type="text" id="childName" name="childName" value=""/>
                  </div>
                  <div>
                        <label for="con_ser">¿¿¿¿¿:</label> <input type="text" id="con_ser" name="con_ser" value=""/>
                  </div>
                  <div>
                        <label for="homePhone">¿¿¿¿¿:</label> <input type="text" id="homePhone" name="homePhone" value=""/>
                  </div>
                  <div>
                        <label for="homeEmail">¿¿¿¿ ¿¿¿¿¿¿¿¿:</label> <input type="text" id="homeEmail" name="homeEmail" value=""/>
                  </div>
                  <div>
                        <label for="con_address">¿¿¿¿¿:</label> <input type="text" id="con_address" name="con_address" value=""/>
                  </div>
                  <div>
                        <label for="con_address">¿¿¿¿¿:</label> <input type="file" id="childPhoto" name="childPhoto"/>
                                    <div id="cPhoto" style="display:inline;float:right;clear:left" >
                                    <img src=""      >
                                    </div>
 
                  </div>
            </div>
            
                  
                  <!--<div class="radio">
                        <fieldset>
                                                                  <div>
                  
                                    <input type="radio" id="1" name="con_gender" value="1" CHECKED> <label for="class">¿¿</label>
                              </div>
                              <div>
                                    <input type="radio" id="2" name="group_type" value="2" ><label for="daycare">¿¿</label>
                              </div>
                              
                        </fieldset>
                  </div>-->
                  
            </fieldset>
                        <fieldset class="contact">
                  
                  
                  
                        <input type="hidden" name="submitted" value="TRUE" />

      
            
  <div><input type="submit" class="more_button" onclick="javascript:document.forms['contact_form']['add_more'].value='TRUE'" id="more" value="¿¿¿¿¿ ¿¿¿"/></div>
<div><input type="submit" class="next_button" id="next" value="¿¿¿¿"/></div>
</form>
<td width="25%"></td>
</tr>
</table>
0
orlyga
Asked:
orlyga
1 Solution
 
Gurvinder Pal SinghCommented:
<<  <div><input type="submit" class="more_button" onclick="javascript:document.forms['contact_form']['add_more'].value='TRUE'" id="more" value="¿¿¿¿¿ ¿¿¿"/></div> >>

Is this that submit button submitting two forms?
Try after removing that onclick attribute.
0
 
themrrobertCommented:
Try using only 1 submit tag per form.

To get around this, create a javascript function that calls the form.submit() function and add
onclick="my_submit_function(); javascript:document.forms['contact_form']['add_more'].value='TRUE'"
0
 
orlygaAuthor Commented:
found out the problem, I was using two hidden fields with the same name to check if form was submitted. The first form, being also reloaded in PHP checked for the value as well.
When I changed the hidden ack "submitted" field, it worked
0
 
Ray PaseurCommented:
With questions at EE, you can post in more than one Zone.  This question might go into the PHP and the HTML Zones, since it is about using PHP to process HTML forms.  Based on this and the other questions of yours, you might get some value from reading the links here:
http://us2.php.net/tut.php

Best regards, ~Ray
0
 
orlygaAuthor Commented:
I found the solution myself
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now