Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/155583-passing-form-results-to-mulitply-files/
Share on other sites

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

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.

 

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.