SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Two or more different "Submit" Buttons in my code calling different or the same websi

    I would like to use two or more different "Submit" Buttons in my code calling different or the same websites.

    How do I do this?

    Code:
                                echo '<form  name="form1" action="total_InsertInto.php" method="post">';
    			    echo '<center><table><tr><td>, '<input name="Textinsertintocol1" type="text" value= "" width="25" />', '</td>';
    			    echo '<td>, '<input name="Textinsertintocol2" type="text" value= "" width="25" />', '</td>';
    			    echo '<td>, '<input name="Textinsertintocol3" type="text" value= "" width="25" />', '</td>';
    			    echo '<td>, '<input name="Submitinsertinto" type="submit" value= "Insert Into" width="25" />', '</td></tr></table></center></form>';
    			   
                                echo '<form  name="form2" action="total_Update.php" method="post">';
    			    echo '<center><table><tr><td>, '<input name="Textupdatecol1" type="text" value= "" width="25" />', '</td>';
    			    echo '<td>, '<input name="Textupdatecol2" type="text" value= "" width="25" />', '</td>';
    			    echo '<td>, '<input name="Textupdatecol3" type="text" value= "" width="25" />', '</td>';
    			    echo '<td>, '<input name="Submitupdate1" type="submit" value= "Insert Into" width="25" />', '</td></tr></table></center></form>';
    
                                echo '<form  name="form3" action="total_Update.php" method="post">';
    			    echo '<center><table><tr><td>, '<input name="Text1updatecol1" type="text" value= "" width="25" />', '</td>';
    			    echo '<td>, '<input name="Text1updatecol2" type="text" value= "" width="25" />', '</td>';
    			    echo '<td>, '<input name="Text1updatecol3" type="text" value= "" width="25" />', '</td>';
    			    echo '<td>, '<input name="Submitupdate2" type="submit" value= "Insert Into" width="25" />', '</td></tr></table></center></form>';

  2. #2
    SitePoint Guru bronze trophy
    Join Date
    Feb 2013
    Posts
    725
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    If I understand, taking these forms and making it into ONE form with three actions. Different actions same website and page, no problem. Different form URL actions determined by the button pushed, not possible as far as I know. Markup could use a little touch up assuming you need to echo it.
    PHP Code:
    <?php
    echo '<form name="form1" action="total_InsertInto.php" method="post">
        <center>
            <table>
                <tr>
                    <td width="25%">, <input name="Textinsertintocol1" type="text" value= "" />'
    '</td>
                    <td width="25%">, <input name="Textinsertintocol2" type="text" value= "" />'
    '</td>
                    <td width="25%">, <input name="Textinsertintocol3" type="text" value= "" />'
    '</td>
                    <td width="25%">, <input name="Submitinsertinto" type="submit" value= "Insert Into" /></td>
                </tr>
            </table>
        </center>
    </form>

    <form name="form2" action="total_Update.php" method="post">
        <center>
            <table>
                <tr>
                    <td width="25%">, <input name="Textupdatecol1" type="text" value= "" />'
    '</td>
                    <td width="25%">, <input name="Textupdatecol2" type="text" value= "" />'
    '</td>
                    <td width="25%">, <input name="Textupdatecol3" type="text" value= "" />'
    '</td>
                    <td width="25%">, <input name="Submitupdate1" type="submit" value= "Insert Into" /></td>
                </tr>
            </table>
        </center>
    </form>

    <form name="form3" action="total_Update.php" method="post">
        <center>
            <table>
                <tr>
                    <td width="25%">, <input name="Text1updatecol1" type="text" value= "" />'
    '</td>
                    <td width="25%">, <input name="Text1updatecol2" type="text" value= "" />'
    '</td>
                    <td width="25%">, <input name="Text1updatecol3" type="text" value= "" />'
    '</td>
                    <td width="25%">, <input name="Submitupdate2" type="submit" value= "Insert Into" /></td>
                </tr>
            </table>
        </center>
    </form>'
    ;
    ?>

  3. #3
    SitePoint Guru bronze trophy
    Join Date
    Feb 2013
    Posts
    725
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    You could determine the action before hand with a separate form.
    PHP Code:
    <?php
    $urls 
    = array("total_InsertInto.php","total_Update.php","total_Update2.php");
    $cnt =  count($urls);
    echo 
    '<form action="" method="post">
        <center>
            <table>
                <tr>
                    <th colspan="' 
    $cnt '">Post to URL</th>
                </tr>
                <tr>'
    ;
                foreach(
    $urls as $url):
                    echo 
    '<td><input type="submit" name="url" value="' $url '" /></td>';
                endforeach;
                    
    echo 
    '            </tr>
            </table>
        </center>
    </form>'
    ;

    $action = (isset($_POST['url']) ? $_POST['url'] : '');
                    
    echo 
    '<form name="form1" action="' $action '" method="post">
        <center>
            <table>
                <tr>
                    <td width="25%">, <input name="Textcol1" type="text" value= "" />'
    '</td>
                    <td width="25%">, <input name="Textcol2" type="text" value= "" />'
    '</td>
                    <td width="25%">, <input name="Textcol3" type="text" value= "" />'
    '</td>
                    <td width="25%">, <input name="Submit" type="submit" value= "Insert Into" /></td>
                </tr>
            </table>
        </center>
    </form>'
    ;
    ?>

  4. #4
    SitePoint Member
    Join Date
    Jun 2014
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should remove one button from your code.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •