form with two buttons

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I want a simple form, but with two buttons: login and logout. I
understand that I can do this by placing a form within a form.

Here is what I have. It looks okay, but the logout button is just like
pressing the login button.

<table border="3" bgcolor="#EEEEEE" width="30%" align="center"
valign="center"  cellpadding="10%">
    <tr><th bgcolor="#6699FF"><font
    <form action="authenticate.php" method=POST>
        <input type="text" name="username">
        <input type="password" name="password">
        <input type="submit" value="Log In">
        <input type="button" value="Log Out"

I have also tried:

        <form action="logout.php">
        <input type="submit" value="Log Out">

But that does not work either.

Re: form with two buttons wrote:
Quoted text here. Click to load it

I have done something similar to this in Perl - the answer is to use
the one script (PHP or Perl) and not two - the script should then check
the value passed to it when called - ie looks for value="Log Out" or
value="Log In"

Rich Mellor

Re: form with two buttons wrote:
Quoted text here. Click to load it

You understand incorrectly. A form cannot contain another form.

Use a single form. Give the two buttons different name attributes. In
the page that the form submits to, find out which of the two names has a
non-blank value embedded in the request, and go on from there.

Re: form with two buttons

Gazing into my crystal ball I observed writing in

Quoted text here. Click to load it

No, you cannot nest forms.  Further, what is the point of having a Login
AND a Logout button?  If the person is already logged in, why would they
need a login button, and if a person is _not_ logged in, why would they
need a logout button?

Best thing to do is test on the server if the person is logged in, and show
the appropriate button.

Adrienne Boswell at Home
Arbpen Web Site Design Services
Please respond to the group so others can share

Site Timeline