rbragg Posted March 9, 2007 Share Posted March 9, 2007 I have a submit-type button named "done". I am doing print testing and initially, this is what is printed: Request_Method = GET Post Data: Array ( ) Sessions: Array ( ) If I enter some values and submit, they are populated into the Post array and not the Sessions array. I have maintained the values and when I submit again, it then populates the values into the Sessions array, however, nothing is able to be passed to the next page. Values are able to be passed to the next page via the Post method. I'm bewildered. <?php session_start(); echo 'Request_Method = ' .$_SERVER['REQUEST_METHOD']; # print testing echo "<br>\n" . 'Post Data: '; @print_r($_POST); echo "<br>\n" . 'Sessions: '; @print_r($_SESSION); echo "<br>\n"; if( $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['done']) ) # only if form is submitted { foreach ($_POST as $key => $value) # put the values into session variables { if ($key != "done") # if user didn't reach this page by submitting { $_SESSION[$key] = strip_tags($value); # strip tags } } include 'lots_validate.php'; # and direct to validate } ?> <form name="lots_choose" method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>"> Link to comment https://forums.phpfreaks.com/topic/42029-problem-storing-values-as-session-variables/ Share on other sites More sharing options...
per1os Posted March 9, 2007 Share Posted March 9, 2007 I am not sure if we are just missing code, but I do not really see where the done part is set. <input type="hidden" value="ok" name="done" /> Probably should be somewhere I hope. If not your data is never entering into that first if statement. --FrosT Link to comment https://forums.phpfreaks.com/topic/42029-problem-storing-values-as-session-variables/#findComment-203801 Share on other sites More sharing options...
Liquid Fire Posted March 9, 2007 Share Posted March 9, 2007 could you post the full code for the form? Link to comment https://forums.phpfreaks.com/topic/42029-problem-storing-values-as-session-variables/#findComment-203803 Share on other sites More sharing options...
rbragg Posted March 9, 2007 Author Share Posted March 9, 2007 Sure guys: <?php session_start(); echo 'Request_Method = ' .$_SERVER['REQUEST_METHOD']; # print testing echo "<br>\n" . 'Post Data: '; @print_r($_POST); echo "<br>\n" . 'Sessions: '; @print_r($_SESSION); echo "<br>\n"; if( $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['done']) ) # only if form is submitted { foreach ($_POST as $key => $value) # put the values into session variables { if ($key != "done") # if user didn't reach this page by submitting { $_SESSION[$key] = strip_tags($value); # strip tags } } include 'lots_validate.php'; # and direct to validate } ?> <form name="lots_choose" method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>"> <div id="middle_title">Lots</div> <div class="style1" align="right">sign out</div> <div align="center"> <p class="style1">Please choose to open or close the following lots:</p> <table width="25%" border="0" align="center" cellpadding="1" cellspacing="0"> <tr> <td width="15%" class="style2"><u>Lot</u></td> <td width="5%" class="style2"><u>Open</u></td> <td width="5%" class="style2"><u>Close</u></td> </tr> <tr> <td class="style1">11</td> <td><label for="open11" class="style1"> <?php $sticky11= ( (isset($_SESSION['rb11'])) && ($_SESSION['rb11'] == 'open') )?' checked="checked" ':' '; # maintains entry echo '<input type="radio" name="rb11" id="open11" value="open" ' . $sticky11 . '/> '; # displays radiobutton with maintained entry ?> </label></td> <td><label for="close11" class="style1"> <?php $sticky11= ( (isset($_SESSION['rb11'])) && ($_SESSION['rb11'] == 'closed') )?' checked="checked" ':' '; # maintains entry echo '<input type="radio" name="rb11" id="close11" value="closed" ' . $sticky11 . '/> '; # displays radiobutton with maintained entry ?> </label></td> </tr> <tr> <td colspan="3" align="right"><input class="style1" type="submit" name="done" id="done" value="done"></td> </tr> </table> </div> </form> Link to comment https://forums.phpfreaks.com/topic/42029-problem-storing-values-as-session-variables/#findComment-203847 Share on other sites More sharing options...
per1os Posted March 9, 2007 Share Posted March 9, 2007 In the code you posted I do not see where you have placed the done portion. Maybe try adding that input line I posted above after the <form etc...> call. --FrosT Link to comment https://forums.phpfreaks.com/topic/42029-problem-storing-values-as-session-variables/#findComment-203856 Share on other sites More sharing options...
rbragg Posted March 9, 2007 Author Share Posted March 9, 2007 ACK! I'm sorry - I ommitted this when I was removing certain includes that were unrelated to my problem. Please read my modified previous post. Thanks. Link to comment https://forums.phpfreaks.com/topic/42029-problem-storing-values-as-session-variables/#findComment-203862 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.