I have a search page that isn't saving the session. The form shows the search results on the same page. I can submit the form and the search results show. If I leave the page and come back, or reload the page, the form (which is drop down boxes) resets and it acts like you never searched for anything. I have session_start(); at the beginning which I know can be a common problem so that's not it. I want to believe that it has to do with the drop down boxes believe it or not. I say this because I have another search page set up the same way but it uses text boxes instead of drop downs, and it saves the session data just fine. There's something with the drop down box form that resets everything when the page reloads. Any ideas?
if (!isset($_SESSION)) { session_start(); } PHP: sounds like the session is being restarted and loosing the value
Hmm that didn't resolve it. Since that didn't work I think my session just isn't being stored at all. The search results for the 1st page show just because it has the data fresh from the form. But when I go to page 2, I get no results even when adding the code above. So, I'm concluding that for some reason, my session variables aren't being stored. Sigh.
if (isset($_SESSION)) { foreach ($_SESSION as $v => $a) { echo "$v - $a<br/>"; } } PHP: also looking at your code session year, month and day don't get set
I love you! Thank you so much!! I really have been working on this for 3 days straight. All this time I wasn't setting the date for the session.
OK, I thought it was fixed. But I guess not. When I click the next button and go to the next page, the session data is echoed at the top but, it still doesn't show the next results. It shows this at the top, so I know the session data is there. But again, I go to the next page and it doesn't work. year - 2010 month - 07 day - 10 action - godate
looks like you are over writing the session value with an empty post value. This should fix it. if (isset($_POST[year]) { $_SESSION[year]=$_POST[year]; } if (isset($_POST[year]) { $_SESSION[month]=$_POST[month]; } if (isset($_POST[year]) { $_SESSION[day]=$_POST[day]; } PHP:
When I copy and paste that code you provided I get an error and the page doesn't even load. Is this code correct? No matter where in the page I place it, it causes the page not to load. if (isset($_POST[year]) { $_SESSION[year]=$_POST[year]; } if (isset($_POST[year]) { $_SESSION[month]=$_POST[month]; } if (isset($_POST[year]) { $_SESSION[day]=$_POST[day]; } PHP: Wow, who knew sessions would be so difficult? Maybe I need to stop the form from submitting or something? I'm totally confusing myself now.
sorry my bad, didn't close my brackets properly if (isset($_POST[year])) { $_SESSION[year]=$_POST[year]; } if (isset($_POST[year])) { $_SESSION[month]=$_POST[month]; } if (isset($_POST[year])) { $_SESSION[day]=$_POST[day]; } PHP: weird not working in ff, in theory php is the server side producer so should kick out the code no matter what the browser
One quick question, it is working but, why do you repeat the post[year] part three times in your code above instead of doing year, then month, then day?
Sorry bad copy and paste to update, should be: if (isset($_POST[year])) { $_SESSION[year]=$_POST[year]; } if (isset($_POST[month])) { $_SESSION[month]=$_POST[month]; } if (isset($_POST[day])) { $_SESSION[day]=$_POST[day]; } PHP: