loremuel Posted September 29, 2009 Share Posted September 29, 2009 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... :'( Quote Link to comment https://forums.phpfreaks.com/topic/175906-how-can-i-get-variable-to-another-php-file/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 29, 2009 Share Posted September 29, 2009 See this - http://www.phpfreaks.com/forums/index.php/topic,270811.msg1277861.html#msg1277861 Quote Link to comment https://forums.phpfreaks.com/topic/175906-how-can-i-get-variable-to-another-php-file/#findComment-926930 Share on other sites More sharing options...
loremuel Posted September 29, 2009 Author Share Posted September 29, 2009 I don't get it :'( Quote Link to comment https://forums.phpfreaks.com/topic/175906-how-can-i-get-variable-to-another-php-file/#findComment-926940 Share on other sites More sharing options...
Alex Posted September 29, 2009 Share Posted September 29, 2009 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; Quote Link to comment https://forums.phpfreaks.com/topic/175906-how-can-i-get-variable-to-another-php-file/#findComment-926942 Share on other sites More sharing options...
loremuel Posted September 29, 2009 Author Share Posted September 29, 2009 Ahh.. Now I get it about why the 3rd did not get something from the 2nd. thank you so much... 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 Quote Link to comment https://forums.phpfreaks.com/topic/175906-how-can-i-get-variable-to-another-php-file/#findComment-926961 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.