Very Urgent Passing Variables

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
snayak82
Forum Newbie
Posts: 2
Joined: Wed May 19, 2010 1:54 am

Very Urgent Passing Variables

Post by snayak82 »

How can i pass variables from pne php to another without submitting the form
User avatar
hypedupdawg
Forum Commoner
Posts: 74
Joined: Sat Apr 10, 2010 5:21 am

Re: Very Urgent Passing Variables

Post 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?
snayak82
Forum Newbie
Posts: 2
Joined: Wed May 19, 2010 1:54 am

Re: Very Urgent Passing Variables

Post 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 .
User avatar
hypedupdawg
Forum Commoner
Posts: 74
Joined: Sat Apr 10, 2010 5:21 am

Re: Very Urgent Passing Variables

Post 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.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Very Urgent Passing Variables

Post by Jonah Bron »

It's still not clear, but you might be looking for Sessions

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