Jump to content

Passing form results to mulitply files


Bman900

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.

 

Archived

This topic is now archived and is closed to further replies.

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