Forum Moderators: coopster
I have tried putting session_unset on its own and with session_destroy but while typing them into results.php I realised "this aint gonna work" but tried it to make sure and it doesnt, how do I start a new session as the session is vital to the page refresh type navigation. Thanks
The user has 3 boxes they "could" choose from 1 or 2 or all 3 how do I use the $_SESSION index you mentioned?
Do I need to add anything to results.php to do with the session?
Thanks again
If you want to continue using the $_SESSION option that you have implemented then you are correct. You need to start your session at the beginning of the "search.php" script and unset your $_SESSION['mySearch'] variable. That way it won't be carried into your "results.php" script (or whatever script is named in the action attribute of the "search.php" form).
Where do I put the form hidden field and how do I keep it there during the refreshes, sorry for the need of spoon feeding, do you mean set the form method on search.php to "get" rather than "post" or the hidden field for method, and, is that on the results.php page.
How would I push/pull the value from field to field, the links I am using are text rather than buttons.
$search = $_POST['search'];
$sql = "SELECT * FROM table WHERE searchField LIKE '%" . mysql_real_escape_string($search) . "%'";
Well, now all you have to do is make sure you also put that into your "results" form page too.
<form method="post" action="results.php">
<input type="hidden" value="<?php print htmlentities($search); ?>" />
</form>
Or something along those lines. Make sense?
<form method="post" action="date_search_results.php">
<input type="hidden" name="start" value="week_1" />
search.php sends the result of a select box, so theres no string checking, I know whats coming in, I use this pagination script on many pages throughout manysites and thisis the first time it has caused a problem, this could be the reason, the db call isnt the usual
select what from table where column = $string
the column name is actually whats passed from the search page, all otherpages where the script works without loosing the data have the usual where column = $string, is that the cause of this issue?
I cant understand how the hidden field gets passed when a hyperlink is clicked is there a way of making it save its state, have I missed something?
There it is. You aren't using a form with a post method, you are using a hyperlink, just like at google. Have a closer look at how google carries the search term from page to page. As you hover over the "next" link, look at the status bar in your browser. You see the "search" keyword along with it's value in the link? That is how the state is being maintained. Scrap the hidden form field and add the search query to your hyperlink and you will maintain the state.