Jump to content

Saving & calling User Information in Pagination


worleyjbird

Recommended Posts

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.