passing a post value to 2 scripts

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
petrosa
Forum Newbie
Posts: 12
Joined: Fri Feb 27, 2009 9:13 pm

passing a post value to 2 scripts

Post by petrosa »

Hi all,

My first post on the forums, since i am stack at a particular problem.

I have a form, and i pass values with the post method. Now the problem is, that this value must be passed to two different php scripts, and the first script has a function in it that calls the second script. Its an sql query, and cant seem to be able to make it work with a variable in the query. When i place a standard value, it works fine.

I tried to require the first script in the second one and use the value from that one, but cant make it work.

Appreciate any help
Looking forward to an answer
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: passing a post value to 2 scripts

Post by susrisha »

Can you post us the code for both of your scripts so that we can suggest you a solution.?

Since you are new.. i am just suggesting to please post the code in appropriate tags.
petrosa
Forum Newbie
Posts: 12
Joined: Fri Feb 27, 2009 9:13 pm

Re: passing a post value to 2 scripts

Post by petrosa »

I am building a google maps application, and i have a search option for price, that i pass with post method

The script that the post action calls (generatePrice.php) gets the post value with
$var = @$_POST['q'] ;
and at some point, i have the following code

Code: Select all

GDownloadUrl("generateXML.php", function(data) {
          var xml = GXml.parse(data);
           var markers = xml.documentElement.getElementsByTagName("marker");


Now, my generateXML.php script, needs that same value that was posted to generatePrice.php, so i can make an sql query on my db, and get the search results.

Thanks for your time
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: passing a post value to 2 scripts

Post by susrisha »

you can send the value in session if its in the same server. Else you need to send it as a get variable

generateXML.php?q=$_POST['q'] ;

in the generateXML.php file, access the same as $var = $_GET['q'];

See if this is what you are looking for.
petrosa
Forum Newbie
Posts: 12
Joined: Fri Feb 27, 2009 9:13 pm

Re: passing a post value to 2 scripts

Post by petrosa »

Thank you for your answer, i have used

Code: Select all

session_start();
 
  $var = $_GET['q'] ;
  session_register('var');
It works like a charm!! You have just made my day!

Thank you so much !
Post Reply