Page 1 of 1

Very Urgent Passing Variables

Posted: Wed May 19, 2010 1:58 am
by snayak82
How can i pass variables from pne php to another without submitting the form

Re: Very Urgent Passing Variables

Posted: Wed May 19, 2010 2:18 am
by hypedupdawg
Ummmm....? Do you mean two scripts in the same page? In which case all you need to do is declare variables outside the functions:

Code: Select all

<?php
$i = 0;
function doStuff ()
{
//do something to $i
}
?>
Or a different page altogether? in which case you can use the $_GET method by sending an URL such as "http://your.page.com/index.php?i=0&j=3" (i and j being the variables). you can then pick them up on the second page using:

Code: Select all

<?php
$newvar = $_GET['i'];
$newvar2 = $_GET['j'];
?>
Or on the same page, to an external script, without refreshing? In which case you need to investigate AJAX, using a combination of php and javascript.

A you can see, more details would help indefinitely :D. Any reason why it's urgent?

Re: Very Urgent Passing Variables

Posted: Wed May 19, 2010 3:32 am
by snayak82
<input type="text" id="MARKET_PROVIDER_KY" name="PROVIDER_KY_MKT" b:required="true"/>

<b:button id="market_fetch_button">Fetch
<s:event b:on="command">
<s:task b:action="load" b:method="get" b:url="all/MarketingInputBdy.php" b:destination="id('Mkrtng_bdy')" b:mode="replace" />

<s:task b:action="show-hide" b:target="id('buttonDiv')" />
</s:event>
</b:button>

This is my code .....in the current php and am trying to execute the query defined in another php for which i need to pass the input type defined in my current php .And i am submitting my current php to
a different php .So i need to pass the input type value to the all/MarketingInputBdy.php .

Re: Very Urgent Passing Variables

Posted: Wed May 19, 2010 5:46 am
by hypedupdawg
You've defined the method as "get" and I presume the id is "'Mkrtng_bdy' - so on your recieving page, you need to have a statement like this:

Code: Select all

$newVar  = $_GET['Mkrtng_bdy'];
I don't understand what your first query was about - not submitting the form? Could you please elaborate? For either of these methods, you need to submit the form for it to work. Otherwise, you will need to use an AJAX method.

Re: Very Urgent Passing Variables

Posted: Wed May 19, 2010 12:28 pm
by Jonah Bron
It's still not clear, but you might be looking for Sessions

http://us3.php.net/manual/en/book.session.php