tags:

views:

58

answers:

3

i have a form, i want to send form data to two different action, can I do that in php

+1  A: 

No it's not possible to send form data to two different actions simultaneously (you can send form data by calling other method from the action called in the form ) using PHP or any other programming langauage

Salil
Using bold makes it stand out more than putting it in a code block (which it doesn't belong in)...
animuson
+1  A: 

I think the only way would be something like this:

if($_SERVER['REQUEST_METHOD'] == 'POST') {
    switch ($_POST['action']) {
        case 'action1':
             // do something
        break;
        case 'action2':
             // do something
        break;
    }
}

Where you would have a hidden input in your form, which would contain type of the action you want to do. Then after the form is submited, you switch the action and do what you need.

The only other way, without PHP, would be to use AJAX as many of the answers in related questions suggest.

realshadow
A: 

No that is impossible because how would the browser know which page to send the user to (that is all an action is).

However, you could have it post to a PHP page that then fires the form submit to two separate actions (only makes sense for different webapps - if it's the same app could just pass to a function call).

Graphain