sebchiken
sebchiken

Reputation: 11

How to form post to two different php files using action?

So here's my code

<form class="form-signin" action="formProcess.php" action="Portal.php" action="Blog.php"    method="post">

but it seems to be only sending the form info to formProcess.php. I can tell because I am not able toto pull the form data on Portal.php. Here's my variables:

$sitename = $_POST['siteName'];

but I try to use it later down in the code:

<a class="navbar-brand" rel="home" href="#"><? echo $sitename; ?></a>

and it does not display $sitename on my page. We have tried using $test = ('hi'); and it echoes hi just fine.

Upvotes: 0

Views: 9736

Answers (2)

Alexandru Severin
Alexandru Severin

Reputation: 6228

You can't have multiple instances of the same attribute inside a html tag, having multiple action targets isn't suggested, and if you can join php scripts as panther suggested you should do it.

If however you cannot alter the php files and you prefer to retrieve data from each of them individually you may call a javascript function that then calls your php scripts, as such:

<form action="javascript:callPHP()" action="formProcess.php">

Javascript:

function callPHP(){
   $.post( "formProcess.php", function( data ) {
       // handle data from formProcess.php
   });
   $.post( "Portal.php", function( data ) {
       // handle data from Portal.php
   });
   // etc
}

Upvotes: 1

pavel
pavel

Reputation: 27072

The first one attribute is used, the others of the same name are ignored.

If you need to put data in two different scripts (st. is wrong here, why you need that?), include Portal.php inside the processing of form data in formProcess.php.

Upvotes: 2

Related Questions