Two "form action's" on one line

17,640

Solution 1

<span style="float:left;">
    <form action='logout.php' method='POST'>           
        <input type='submit' value='Logout' />      
    </form>   
</span>
<span style="float:right;">
    <form action='changepassword.php' method='POST'>     
        <input type='submit' value='Change password' />       
    </form>
</span>

Solution 2

If I understand your question properly, I think you need to use some CSS:

form {
    float: left;
    width: auto;
}

You might want to add a class to those forms to stop yourself styling all forms like this

Solution 3

Here's the dirty inline version

<form action='logout.php' method='POST' style='float:left;'>           
<input type='submit' value='Logout' />      
</form>                      
<form action='changepassword.php' method='POST'>     
<input type='submit' value='Change password' />       
</form>

Of course James's suggestion to use a class is the proper way to do it.

Btw, those forms should be after the opening body tag.

Share:
17,640
connor.p
Author by

connor.p

hello, my name is Connor Perrin. I'm 18 years old and have been programming now for nearly 2 years, I currently go to 6th form and have plans to go to university to study computer science. why do i like programming? i guess one of the main reasons i like programming is because of the feeling you get when you complete a challenge or fix a problem. I also like seeing a project or challenge come to life and facing the odd problem of forgetting to put a ; at the end of a statement

Updated on June 08, 2022

Comments

  • connor.p
    connor.p almost 2 years

    I have just finished putting a login and register bit on my website and now I'm just cleaning things up, but then I came to this problem I have two form action's on one page, each one goes to a different page, easy enough, but I can't seem to get them both on one line.

    Here is the code for the form actions:

    <form action='logout.php' method='POST'>           
    <input type='submit' value='Logout' />      
    </form>                      
    <form action='changepassword.php' method='POST'>     
    <input type='submit' value='Change password' />       
    </form>
    

    I've tried

    <form action='logout.php' method='POST'>           
    <input type='submit' value='Logout' />                           
    <form action='changepassword.php' method='POST'>     
    <input type='submit' value='Change password' />       
    </form>
    

    but both buttons go to the same location

    the website is www.crossception.com, you will need to login to get to this problem I've already made a login and password for every one to use username : stackoverflow password : test101

    thank you very much
    connor
    (aged 15)