Bman900 Posted April 25, 2009 Share Posted April 25, 2009 Ok, so I have a a form that post the information in variables in a page called redirect.php (Includes a lot of HTML) than I have another page calles page1.php where I want to access the variables I have passed my information from my form to. I tried to use include() but I guess since my redirect.php is not completely php it doesn't work because it messes up my entire design on page1.php Any one? Quote Link to comment https://forums.phpfreaks.com/topic/155583-passing-form-results-to-mulitply-files/ Share on other sites More sharing options...
RussellReal Posted April 25, 2009 Share Posted April 25, 2009 session.. at the start of the page you direct your form to.. do this: <?php session_start(); $_SESSION[] = $_REQUEST; ?> Quote Link to comment https://forums.phpfreaks.com/topic/155583-passing-form-results-to-mulitply-files/#findComment-818798 Share on other sites More sharing options...
Bman900 Posted April 25, 2009 Author Share Posted April 25, 2009 I kind of get this, would I call this session in my page1.php to get the variable or is it done differently? Quote Link to comment https://forums.phpfreaks.com/topic/155583-passing-form-results-to-mulitply-files/#findComment-818801 Share on other sites More sharing options...
RussellReal Posted April 25, 2009 Share Posted April 25, 2009 as soon as you add it to the session, it should be accessible in every page, but instead of using $_POST you'd use $_SESSION to access it (AFTER you initiate the session using session_start ofcourse ) Quote Link to comment https://forums.phpfreaks.com/topic/155583-passing-form-results-to-mulitply-files/#findComment-818805 Share on other sites More sharing options...
Bman900 Posted April 25, 2009 Author Share Posted April 25, 2009 do i need to activate session() on my page1.php as well? Quote Link to comment https://forums.phpfreaks.com/topic/155583-passing-form-results-to-mulitply-files/#findComment-818807 Share on other sites More sharing options...
RussellReal Posted April 25, 2009 Share Posted April 25, 2009 session_start just gives you access to the session with the user.. its nothing special.. if you used the superglobal $_SESSION without initiating the session via session_start it will do absolutely nothing.. ofcourse it will still function as a variable, but will not do what it was designed to do, save the data inside at the garbage collection stage of the php process, to a session file, for use in another php execution, if you initiate a session with the same user, using the same php session id.. so if you're going to use your session in 'page1.php' yes, you need to initiate the session.. Quote Link to comment https://forums.phpfreaks.com/topic/155583-passing-form-results-to-mulitply-files/#findComment-818808 Share on other sites More sharing options...
Bman900 Posted April 26, 2009 Author Share Posted April 26, 2009 Alright so would I have this on my form direct page: session(); $question = $_SESSION['question']; $firstname = $_SESSION['name_first']; instead of $question = $_POST['question']; $firstname = $_POST['name_first']; Quote Link to comment https://forums.phpfreaks.com/topic/155583-passing-form-results-to-mulitply-files/#findComment-819328 Share on other sites More sharing options...
Bman900 Posted April 26, 2009 Author Share Posted April 26, 2009 Alright scratch the above post, how do I put a variable into the $_SESSION and how do I access that in other pages? Quote Link to comment https://forums.phpfreaks.com/topic/155583-passing-form-results-to-mulitply-files/#findComment-819343 Share on other sites More sharing options...
stickynote427 Posted April 26, 2009 Share Posted April 26, 2009 redirect.php <?php session_start(); $_SESSION['question']=$_POST['question']; $_SESSION['firstname']=$_POST['name_first']; ?> page1.php <?php session_start(); //do whatever you want with the $_SESSION variables here, for example... echo "Hello, " . $_SESSION['firstname'] . "! ".$_SESSION['question']; //this might echo "Hello, Bman! Would you like some help with PHP?" ?> I think, but I'm honestly not 100% sure. Quote Link to comment https://forums.phpfreaks.com/topic/155583-passing-form-results-to-mulitply-files/#findComment-819394 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.