a1amattyj Posted March 3, 2008 Share Posted March 3, 2008 hi, very new with sessions here. currently on a "install" code which will install my script. the the pages are all install.php?step=1 ..2..3 etc etc The first page asks for you details then the second grabs them : $database_name = ($_POST['database_name']); $database_password = ($_POST['database_password']); $database_user = ($_POST['database_user']) then checks for errors and trys to connect.. now, how can i pass this information from install.php?step=1 all the way to step=.. lets say 6 i guess session is the best? can someone please advise on how i pass this by a session for the variable $database_name. Thanks Link to comment https://forums.phpfreaks.com/topic/94177-php-sessions-help/ Share on other sites More sharing options...
discomatt Posted March 3, 2008 Share Posted March 3, 2008 Sessions is the easiest way. You can also dynamically generate hidden form fields to achieve this as well Link to comment https://forums.phpfreaks.com/topic/94177-php-sessions-help/#findComment-482390 Share on other sites More sharing options...
soycharliente Posted March 3, 2008 Share Posted March 3, 2008 It would probably be helpful to read the manual on sessions, but as a start... One page 1... <?php session_start() // will initiate if it hasn't already and will do nothing if it has $_SESSION["username"] = $_POST["username"]; ?> On page 6... <?php session_start() echo "Welcome to the last page " . $_SESSION["username"]; ?> Link to comment https://forums.phpfreaks.com/topic/94177-php-sessions-help/#findComment-482396 Share on other sites More sharing options...
ohdang888 Posted March 4, 2008 Share Posted March 4, 2008 be sure to have : session_start() as the very first line of every page, becuase if not, the session will be lost. Link to comment https://forums.phpfreaks.com/topic/94177-php-sessions-help/#findComment-482496 Share on other sites More sharing options...
revraz Posted March 4, 2008 Share Posted March 4, 2008 And don't forget the ; after them. And it won't be lost, it just won't be available for that page you dont start it on. Link to comment https://forums.phpfreaks.com/topic/94177-php-sessions-help/#findComment-482505 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.