lewashby Posted October 2, 2013 Share Posted October 2, 2013 I've scooped up the variables via $_POST from and html from and now they're available in my current php script/file. But what if I wanted to send those values to another php script that will not have the luxury using $_POST to gather the html form variables since the form points to the script that executed/called the current script, not the current script it's self. Any ideas on how I can accomplish this? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/282660-script-to-script-valuevariable-transfer/ Share on other sites More sharing options...
AbraCadaver Posted October 2, 2013 Share Posted October 2, 2013 Depends. Do you want to redirect to this new page and pass it vars or do you want to call it "behind the scenes" and receive its output? Quote Link to comment https://forums.phpfreaks.com/topic/282660-script-to-script-valuevariable-transfer/#findComment-1452335 Share on other sites More sharing options...
Irate Posted October 2, 2013 Share Posted October 2, 2013 If you declare global variables, then yes, you can transfer variables to another script. Local variables, not so much. Variable scope's the keyword if you happen to struggle on that. Quote Link to comment https://forums.phpfreaks.com/topic/282660-script-to-script-valuevariable-transfer/#findComment-1452336 Share on other sites More sharing options...
AbraCadaver Posted October 2, 2013 Share Posted October 2, 2013 If you declare global variables, then yes, you can transfer variables to another script. Local variables, not so much. Variable scope's the keyword if you happen to struggle on that. Quote Link to comment https://forums.phpfreaks.com/topic/282660-script-to-script-valuevariable-transfer/#findComment-1452338 Share on other sites More sharing options...
Irate Posted October 2, 2013 Share Posted October 2, 2013 ... Nevermind me... Was thinking of something completely different. Quote Link to comment https://forums.phpfreaks.com/topic/282660-script-to-script-valuevariable-transfer/#findComment-1452340 Share on other sites More sharing options...
lewashby Posted October 3, 2013 Author Share Posted October 3, 2013 I have a script that gets it's values via $_POST and then jumps to another script via the header() function, so I need to somehow pass the variables from the first script to the one that the header function jumps to. I think I need to take a look into sessions. Quote Link to comment https://forums.phpfreaks.com/topic/282660-script-to-script-valuevariable-transfer/#findComment-1452438 Share on other sites More sharing options...
Solution AbraCadaver Posted October 3, 2013 Solution Share Posted October 3, 2013 Sessions or if they are simple vars that don't need to be hidden you can put them as get params in the redirect URL: header("Location: www.example.com/page.php?var=$var1&var2=$var2'); Then get them on the next page: echo $_GET['var1']; But I would probably use sessions, and it will be handy to learn them. Quote Link to comment https://forums.phpfreaks.com/topic/282660-script-to-script-valuevariable-transfer/#findComment-1452439 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.