473,396 Members | 2,057 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

maintaining state with sessions - help

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>
Jul 17 '05 #1
5 2234
"leegold2" wrote:
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’;
?>

[back-arrow]form action="search_test2.php" method="post">
<p>Your key word: <input type="text" name="key_word"
/></p>
<p><input type="submit" /></p>
</form>


Leegold,
In this particular case, don’t use sessions. Why? because, lets say
the user is conducting multiple keyword searches at the same time.
The session would cause the subsequent pages of search results to use
the wrong keywords!
You MUST use ’GET’ in this case, to be safe.

to pass multiple variables, you pass them thru urlencode() and then
attach them to the url. Then on the new page, you simply
read the variable via "GET" and parse the keywords using space as
the seperator.

As far as Q2, I am not very clear. But you simply assign your
keywords to the $_SESSION and read them
on the subsequent pages. You have it right (but not recommended for
keyword paging).

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-maintain...ict132921.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=443883
Jul 17 '05 #2
steve wrote:
"leegold2" wrote:
> 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’;
> ?>
>
> [back-arrow]form action="search_test2.php" method="post">
> <p>Your key word: <input type="text" name="key_word"
> /></p>
> <p><input type="submit" /></p>
> </form>


Leegold,
In this particular case, don’t use sessions. Why? because, lets say
the user is conducting multiple keyword searches at the same time.
The session would cause the subsequent pages of search results to use
the wrong keywords!
You MUST use ’GET’ in this case, to be safe.

to pass multiple variables, you pass them thru urlencode() and then
attach them to the url. Then on the new page, you simply
read the variable via "GET" and parse the keywords using space as
the seperator.


It's a mess AFAIK because I'm trying Boolean FULLTEXT and
I have to pass w/GET literally eg. '+high +altitude' and it's
giving me strange results. If I got a form passing that w/GET
what do I do?


As far as Q2, I am not very clear. But you simply assign your
keywords to the $_SESSION and read them
on the subsequent pages. You have it right (but not recommended for
keyword paging).

Jul 17 '05 #3
leegold2 wrote:
I'm starting a new thread cause i think I need rawurlencode()
I'm getting strange results from my GET - imo I should start
w/fresh ques/thread in this group.
steve wrote:
"leegold2" wrote:
> 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’;
> ?>
> > [back-arrow]form action="search_test2.php" method="post">
> <p>Your key word: <input type="text" name="key_word"
> /></p>
> <p><input type="submit" /></p>
> </form>


Leegold,
In this particular case, don’t use sessions. Why? because, lets say
the user is conducting multiple keyword searches at the same time. The
session would cause the subsequent pages of search results to use
the wrong keywords!
You MUST use ’GET’ in this case, to be safe.

to pass multiple variables, you pass them thru urlencode() and then
attach them to the url. Then on the new page, you simply
read the variable via "GET" and parse the keywords using space as
the seperator.

It's a mess AFAIK because I'm trying Boolean FULLTEXT and
I have to pass w/GET literally eg. '+high +altitude' and it's
giving me strange results. If I got a form passing that w/GET
what do I do?


As far as Q2, I am not very clear. But you simply assign your
keywords to the $_SESSION and read them
on the subsequent pages. You have it right (but not recommended for
keyword paging).

Jul 17 '05 #4
"leegold2" wrote:
steve wrote:
"leegold2" wrote:

....
It’s a mess AFAIK because I’m trying Boolean FULLTEXT and
I have to pass w/GET literally eg. ’+high +altitude’ and
it’s
giving me strange results. If I got a form passing that w/GET
what do I do?

Leegold, it should be relatively easy to do. So let’s say the user
input
$a = "high altitude" then you attach to url "&keywords=" .
urlencode($a);
You also pass the paging info, i.e. what page is the next page, e.g.
you attache "&page=2" to the url. Now you are done.

When the new page script is executing, you simply read
$_GET[’keywords’] and it would be equal to "high altitude".

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-maintain...ict132921.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=444087
Jul 17 '05 #5
"leegold2" wrote:
leegold2 wrote:
I’m starting a new thread cause i think I need rawurlencode()
I’m getting strange results from my GET - imo I should start
w/fresh ques/thread in this group.
</font>


Why don’t you set up two simple scripts, where one calls the other.
Assign the keywords as we discussed, and see how it comes out in
$_GET. Everyone is using this, so you don’t need any new functions.
If you do simple scripts, then you can post them here, and we can help
u.

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-maintain...ict132921.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=444111
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: lost hope | last post by:
hey guys, on the main page of my site, i have a login area (user/pass text boxes). when the user submits the form, the page is reloaded with with a global php variable "loggedIn" set to true. i...
2
by: John A Grandy | last post by:
for high traffic public websites , what are the proven options for session-state storage & management ? is an out-of-process state-server generally preferred over a sql-server ? what are the...
5
by: ASP.Confused | last post by:
As you can tell from my previous posts on this issue...I'm really confused :-/ I have a few ASP.NET web applications on my web host's "https" server. Our web host has a single "bin" folder for...
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
9
by: AndersBj | last post by:
Hi all, I have a web application that uses State Server for session handling. The web application randomly loses all session variables. The sessions are not always lost, sometimes I can use the...
5
by: Sean | last post by:
Problem with sessions I have created an application without concern for sessions. As it turns out I think that might be my undoing. What I have: I have an online quiz. I don’t need to know...
4
by: jack | last post by:
Hi , please help me in this I have created a login page which creates a ticket. and im getting my inbox page of my project . ( just for the info. ) The problem is that when i have a page in the...
9
by: cashdeskmac | last post by:
I have put a string into Session and tried to retrieve it on the next page I visit but the Session appears empty. I have exactly the same spelling for both adding and retrieving the value: ...
2
by: aswin.paranji | last post by:
Hi All, Currently I'm working on a migration project from asp to asp.net. I use a tool asp2aspx to migrate the asp pages. the problem is when i migrate to asp.net 2.0 i'm getting lots of...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.