worleyjbird Posted July 24, 2008 Share Posted July 24, 2008 Hi All, I have a page that allows users to search for a product. When there are more than, say, 25 products I get the pagination at the bottom of the page. Here's the kicker, on the main search page, users can input text into a text area. The issue is that (a) Once I click next to go to page 2, the data gets wiped out. And (b) If I click back to page 1, the text is wiped out as well. I want the user to type something and when they navigate to different pages, the text will always be there, regardless of how many pages the search results display. I created a session but its not working. When I echo the session to check for the text it says: "["sample_text"]=> string(0) "" }" I know it might sound strange that people are inputting text on a search page. They are really unrelated but the text is displayed along with the search results and thus I need to maintain that text when going from page to page, etc. Any information would be greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/116505-saving-calling-user-information-in-pagination/ Share on other sites More sharing options...
willpower Posted July 24, 2008 Share Posted July 24, 2008 sessions are you r way forward...i just dont think you have set the session up correctly...code would be useful here Link to comment https://forums.phpfreaks.com/topic/116505-saving-calling-user-information-in-pagination/#findComment-599077 Share on other sites More sharing options...
worleyjbird Posted July 25, 2008 Author Share Posted July 25, 2008 Thanks for the response. The first line is what I added, the rest of the code checks to see if the user inputted any text. I'm not showing the echo statement which is later in the script but I'm assuming that isn't needed here because its printing the session, just not the 'sample_text'. $_SESSION['sample_text'] = htmlspecialchars($_POST['sample_text']); if(isset($_SESSION['sample_text'])) { $render_text_value = htmlspecialchars($_SESSION['sample_text'], ENT_COMPAT, 'UTF-8'); } elseif (isset($_POST['sample_text'])) { $render_text_value = htmlspecialchars($_POST['sample_text'], ENT_COMPAT, 'UTF-8'); } elseif (isset($_GET['sample_text'])) { $render_text_value = htmlspecialchars($_GET['sample_text'], ENT_COMPAT, 'UTF-8'); } else { $render_text_value = DEFAULT_RENDER_TEXT; } Hope this helps. Link to comment https://forums.phpfreaks.com/topic/116505-saving-calling-user-information-in-pagination/#findComment-599086 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.