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... :'(

Link to comment
Share on other sites

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;

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.