kizofilax Posted May 10, 2009 Share Posted May 10, 2009 Hello, i have been having problems in getting my POST variables through multiple pages using sessions Here is the first part of my code for the first page called "statePage1.php" <?php session_start(); $SESSION["p1_q1"]=$_POST["p1_q1"]; ?> <html> <body> <h1>This is the first page</h1> <form id="page1" name="page1" method="post" action="statePage2.php"> <table> <tr> <td>Q1: </td> <td><input type="text" id="p1_q1" name="p1_q1" /></td> This is part of the second page "statePage2.php" <?php session_start(); Print_r ($_SESSION); ?> <html> <body> <h1>This is the second page</h1> The print function doesnt print anything so i dont know why the variables are not getting assigned to the SESSION var. When i do on the first page $SESSION["p1_q1"]="TEST"; it prints it on the second page but when I use the variables from the POST and the form i cant get it to work Any ideas? Thanks Link to comment https://forums.phpfreaks.com/topic/157553-solved-passing-post-variables-through-sessions/ Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 The form in the first page sends the data to the second page, so setting $_SESSION['p1_q1'] to $_POST['p1_q1'] on page one is useless because $_POST['p1_q1'] is empty at that time. You should have placed that in page 2 instead. Link to comment https://forums.phpfreaks.com/topic/157553-solved-passing-post-variables-through-sessions/#findComment-830741 Share on other sites More sharing options...
kizofilax Posted May 10, 2009 Author Share Posted May 10, 2009 The form in the first page sends the data to the second page, so setting $_SESSION['p1_q1'] to $_POST['p1_q1'] on page one is useless because $_POST['p1_q1'] is empty at that time. You should have placed that in page 2 instead. OK its working now!! Thanks =D Link to comment https://forums.phpfreaks.com/topic/157553-solved-passing-post-variables-through-sessions/#findComment-830752 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.