Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 20-10-2009
Member
 
Join Date: Jun 2009
Posts: 87
Problem of html form with multiple submit buttons

Here is my concern: I have a mini-site which allows making pages. Several users have access to my database. First: authentication, once past this page, it displays the list of existing records and according to the author of said sheets, the possible actions are not the same:

(I use real names, so I've hidden)
Here, for example, I am connected with the name D. and if I click Play, it works, I get page I want. Edit and Delete the same. But if I click on Read other lines, I always see the user D

If I switch users, the problem remains the same. Each button leads to information about the connected user. I also have an Administrator user who can normally do anything (view, edit, delete), but then he saw that the last sheet created (by the user F)

Here is the form code where there is the list:

HTML Code:
<body>
    <form action="modify.php" method="post">
        <table id="list">
            <tr>
                <th>
                      Title page |
                </th>
                <th>
                      Date modified |
                </th>
                <th>
                      Author of the page |
                </th>
                <th colspan="3">
                      Available actions
                </th>
            </tr>
    <?php
    $co = new PDO('mysql:host=127.0.0.1;dbname=pwet', $_SESSION['login'], $_SESSION['pwd']); 
   
    $list=$co->query("SELECT id, owner, date_redac, nom FROM page ORDER BY id ASC";); 
    $list->setFetchMode(PDO::FETCH_OBJ); 
    while($tri=$list->fetch()){ 
    ?>
        <?php
            $list_date = $tri->date_redac;
            list($yyyy, $mm, $dd) = explode("-", $list_date);
            $list_date = "$dd-$mm-$yyyy";
        ?>   
               <tr style="<?php if($user == $tri->owner){
                                echo "background-color: #b5e2f9;";
                              }else{
                                echo "background-color: #ff8c8c;";
                            }
                            if($user == "Administrator";){
                                echo "background-color: #9cff8c";
                            }?>">
            <?php if($user == $tri->owner || $user == "Administrator";){?>
            <td>
                <?php echo $tri->name;?>
            </td>
            <td>
                <?php echo $list_date;?>
            </td>
            <td>
                <?php echo $tri->owner;?>
            </td>
            <td colspan="3">
                <input type="hidden" name="id_select" value="<?php echo $tri->id;?>" />
                <input type="submit" name="save" value="Read" />
                <input type="submit" name="page_to_modify" value="Edit" />
                <input type="submit" name="page_to_delete" value="Remove" />
            </td>
        <?php } else { ?>
            <td>
                <?php echo $tri->name;?>
            </td>
            <td>
                <?php echo $list_date;?>
            </td>
            <td>
                <?php echo $tri->owner;?>
            </td>
            <td colspan="3">
                <input type="submit" name="save" value="Read" />
            </td>
        <?php
        }
    }
    $list->closeCursor(); 
    ?>
            </tr>
        </table>
    </form>
</body>
Normally, the id of my statement should be recovered and sent to the next page (modify.php). Is there a transformation of the type of variable to (id which is used in a mysql query to call the correct data based on the id supplied)?

I doubt that it shits in the multiple submit buttons, but I do not know how to fix it while keeping the layout and the current navigation

Any ideas?
Reply With Quote
  #2  
Old 20-10-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
Re: Problem of html form with multiple submit buttons

If you do a print_r($_POST); in modify.php, which variables do you see in your form?
Reply With Quote
  #3  
Old 20-10-2009
Member
 
Join Date: Jun 2009
Posts: 87
Re: Problem of html form with multiple submit buttons

If I click on Read get: "Array ([id_select] => 74 [save] => Read)" and that, whatever the button "Read" on which I click. 74 being the id of the record written by the bilingual connected at that time. If I change my name, I see the id of the ticket he wrote.

To Change, I: Array ([id_select] => 74 [page_to_modify] => Edit).
Reply With Quote
  #4  
Old 20-10-2009
Member
 
Join Date: Jan 2008
Posts: 1,515
Re: Problem of html form with multiple submit buttons

I could be wrong, but I think that one should not use form in this case, just the link with variable. (after so visually like buttons, you use <button>this spike)
Reply With Quote
  #5  
Old 20-10-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
Re: Problem of html form with multiple submit buttons

Your problem is that your hidden field "id_select" is duplicated as many times as you got lines in your table, so I think the browser is sending the first or last, but still the same. putting a name like "id_select []", it would, or else, "id_select" concatenated to the id for "id_select74" for example.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Problem of html form with multiple submit buttons"
Thread Thread Starter Forum Replies Last Post
How to Submit a Form Using JavaScript? Damien25 Software Development 4 07-02-2010 07:05 AM
Verify the content of the textbox with multiple buttons on Form Gadhadhar Software Development 5 23-01-2010 02:19 PM
How to submit form without "Submit Button"? AK_Chopra Software Development 3 10-09-2009 08:44 AM
Several submit buttons in the same form ? Wiro Software Development 5 14-02-2009 10:29 PM
Problem Submit Form in Firefox [javascript] Swetlano Software Development 0 09-02-2009 11:07 PM


All times are GMT +5.5. The time now is 07:27 AM.