Jump to content

How can I get variable to another php file?


loremuel

Recommended Posts

I have 3 php files.. the 1st one gives variable and the 2nd php get the variable of the 1st php but then the 3rd php cannot get the variable from the 1st php..

 

this is the variable in my 1st php file

name="field"

 

this variable will get to the 2nd php file...

$field = $_POST['field'];

echo $field;

it works to get the variable...

 

but in the 3rd php file, I code it again:

$showfield = $_POST['field'];

echo $showfield;

but it's not working...

 

please help me about my case... :'(

It was explained pretty well by PFMaBiSmAd on that link..

 

The reason why on the 3rd page you're not getting the data is because it's only posted directly to that 2nd file, if you want to have to available later on I'd use a session

 

Example:

 

1st:

name="field"

 

2nd:

session_start();

$field = $_POST['field'];

$_SESSION['field'] = $field;

 

3rd:

session_start();

$showfield = $_SESSION['field'];

echo $showfield;

Ahh.. Now I get it about why the 3rd did not get something from the 2nd.

thank you so much...  :D

 

There is something wrong when  I use session..

this print out in the page:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\ex1input.php:38) in C:\xampp\htdocs\ex1input.php on line 40

 

Warning:  session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\ex1output.php:39) in C:\xampp\htdocs\ex1output.php on line 42

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.