Probably a newbie question about "state":
My problem is I have a search form, so user enters a keyword <enter>, then this form posts to another page were the result are displayed. But this display page uses pagination to break the results up into several subsequent pages. The 1st page is OK, but 2nd...last display pages loose the key word variable I initially posted.
Seems I could keep passing the keyword with GET, I already use
GET to pass pager info. Or I could try a SESSION way. I'd prefer
not to use cookies.
Ques 1.
How do I pass more than one (say two in this case) variables
to a new page with GET. right nowfor the pager I have eg.
echo "<a href=\"search_test2.php?page=$i\">Page $i</a>";
How would I stick $key_word in there to also pass it on to
the next page? Then at the target page I have now:
$page = $_GET['page'];
So do I just add: $key_word = $_GET['keyword'];
Just snippets would help w/syntax.
Ques 2.
I also want to try a SESSION way to maintain state. Again, I have
a building block but not sure of syntax. How do I conbine the two
blocks below so it will work. I want to maintain state of the user's
input keyword. Not sure how combine the html and the php below.
Thanks.
<?php
session_start(); // start session
$_SESSION['keyword'] = 'key_word';
?>
<form action="search_test2.php" method="post">
<p>Your key word: <input type="text" name="key_word" /></p>
<p><input type="submit" /></p>
</form>
My problem is I have a search form, so user enters a keyword <enter>, then this form posts to another page were the result are displayed. But this display page uses pagination to break the results up into several subsequent pages. The 1st page is OK, but 2nd...last display pages loose the key word variable I initially posted.
Seems I could keep passing the keyword with GET, I already use
GET to pass pager info. Or I could try a SESSION way. I'd prefer
not to use cookies.
Ques 1.
How do I pass more than one (say two in this case) variables
to a new page with GET. right nowfor the pager I have eg.
echo "<a href=\"search_test2.php?page=$i\">Page $i</a>";
How would I stick $key_word in there to also pass it on to
the next page? Then at the target page I have now:
$page = $_GET['page'];
So do I just add: $key_word = $_GET['keyword'];
Just snippets would help w/syntax.
Ques 2.
I also want to try a SESSION way to maintain state. Again, I have
a building block but not sure of syntax. How do I conbine the two
blocks below so it will work. I want to maintain state of the user's
input keyword. Not sure how combine the html and the php below.
Thanks.
<?php
session_start(); // start session
$_SESSION['keyword'] = 'key_word';
?>
<form action="search_test2.php" method="post">
<p>Your key word: <input type="text" name="key_word" /></p>
<p><input type="submit" /></p>
</form>