SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Pragmatic Programmer halfasleeps's Avatar
    Join Date
    Feb 2006
    Location
    Altoona, PA. USA
    Posts
    1,945
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    form with 2 submits and 2 actions?

    I am not sure if this is a "PHP" question but im developing with php so I'll ask it here. if it fits better somewhere else, feel free to move. thanks.

    I have a form on a product page, one submit will add the product to a wishlist, the other will request a price. but depending on which submit button they click on all the variables need to be posted to a different page.

    can anyone please tell me how to do this?

    THANKS
    Altoona Design
    Freelance Flex developer for hire.
    ActionScript Programmer with 8 Years Experience.

  2. #2
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Something like this:
    PHP Code:
    <?php
    if(!empty($_POST['todo'])){
        switch(
    $_POST['todo']){
            case 
    'add':
            echo 
    'add stuff';
            break;
            case 
    'request':
            echo 
    'request stuff';
            break;
        }
    }

    ?>
    <form method="post">
        <input type="submit" name="todo" value="add" />
        <input type="submit" name="todo" value="request" />
    </form>
    Note: there's only one processing page; the "todo" variable is what makes that page decide what to do.


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
  •