SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot DreamDevil's Avatar
    Join Date
    Nov 2000
    Location
    Belgium
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Multibutton Form

    I have a form that submits a username and password. I have a clickable image that submits those variables to a php-page.

    Now I want another button (for new users) that when clicked, submits the username variable to a new page.

    How can I do that. If it possible to have 2 submit buttons that point to 2 different pages in the same form. (because I need to process the variables).

    Hope it's clear

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This one worked for me, I didn't use input type=image though I used staright images with href tags.

    PHP Code:
    <html>
    <
    head>
        <
    title></title>
    </
    head>
    <
    body>




    <
    form action="step1.php" name="form1">
    This one is for step1.php
    <a href="javascript:submitForm('step1.php');"><img src="uploads/freddy.jpg" width="48" height="48" alt="" border="0"></a>

    <
    br><br>
    This one is for step2.php
    <a href="javascript:submitForm('step2.php');"><img src="uploads/freddy.jpg" width="48" height="48" alt="" border="0"></a>
    </
    form>


    </
    body>
    <
    script language="JavaScript1.2">
    <!--
        function 
    submitForm(action) {
            
    document.form1.actionaction;
            
    document.forms[0].submit();
            }
    //-->
    </script>

    </html> 
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    another way would be to do it with two seperate buttons and first reload the page to check the submit values and based on the value do what you want....like this:

    <?
    if isset($action)
    {
    switch($action)
    {
    case "check":
    if (submit=="New User")
    { //action if they clicked the button labeled "New User"
    } else {
    //action to do if they clicked "Old User"
    }
    }
    }

    <form method=POST action="page.phtml?action=check">
    <input type="text" name="user">
    <input type="text" name="password">
    <input type=submit name=submit value="New User">
    <input type=submit name=submit value="Old User">
    </form>

    i just used very similair code in a categories page that freddy helped me out with if you want i could show you that....that might not be clear enough for you...need any help just ask
    signature

  4. #4
    SitePoint Zealot DreamDevil's Avatar
    Join Date
    Nov 2000
    Location
    Belgium
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanx Freddydoesphp


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
  •