Results 1 to 4 of 4

Thread: php form submits to different urls depending on what checkbox is selected

  1. #1
    Join Date
    Jul 2008
    Location
    boston, ma
    Posts
    88
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default php form submits to different urls depending on what checkbox is selected

    Hi,
    I have searched everywhere and tried a few things with no luck.
    I have a php form part of wordpress. I have the form submitting to wordpress and another user management system.

    I want 3 checkboxes and depending which is checked, on submit the form data will go to a separate url.

    I have this so far

    PHP Code:
    <?php if ($_POST["checkbox"] == "Banking")
    {
    onsubmit="multiSubmit(this, 'url1');"
    }
    if (
    $_POST["checkbox"] == "Insurance")
    {
    onsubmit="multiSubmit(this, 'url2');"

    if (
    $_POST["checkbox"] == "Securities")
    {
    onsubmit="multiSubmit(this, 'url3');"

    ?>
    If i didn't do the multiSubmit, the form would only go to wordpress. Right now with that code, I get an error. Any suggestions on why or better solution to how to do this?

    Thanks

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    you're mixing PHP and javascript. They don't work at the same time: PHP won't know which box is checked until after the form is submitted.

    I don't know what the function multiSubmit() does, so I can't help you there.

    possible solutions:

    1) use javascript (jQuery would be easiest).
    When the user clicks the [ submit ] button, fire a function that checks which box is selected, and submit the form to the appropriate url.

    2) use php.
    Make the form submit to a php page that checks which box is selected, and then re-POST the form to the appropriate url.

  3. #3
    Join Date
    Jul 2008
    Location
    boston, ma
    Posts
    88
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default

    Thanks Trag.
    The multiSubmit(); submits the form to 2 locations. Right now I have the form going to Wordpress and another user management system. I'll try option 2, thanks

  4. #4
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    I figured it did something like that, but without seeing the function itself, I couldn't help you.

    If you use PHP to redirect, you might have to use socket connections or cURL to resend the POST variables (as POST). It will depend on how your processing scripts are set up, and if you can modify them at all.

    If it's a "black box," as it were, javascript would be the easier option.

    p.s., it's " traq " ( Q ). good luck!

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
  •