473,404 Members | 2,137 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,404 software developers and data experts.

Help on sessions

Hello there,

A newbie question....any help is appreciated.

I'm trying to create a script that searches a few database tables based
on the search text and user search preferences. I created a PHP script
(search_form.php) that displays textbox, a search button and a
preferences link. The preferences link opens a popup (preferences.html)
and lists search categories (checkboxes - with search only in column1,
column2 etc. or ALL) and a select button. If the users specify the
preferences I call search_form.php with an "prefs[]" array as argument.
In search_form.php I invoke another script (search.php) - to display
search results - based on user preferences and search text entered.

My question is, how do I make the script remember these preferences and
search text (if user selects links like "Back to Search Results" or
"Back to new search" in other pages) till he closes the existing
window. I understand I can use PHP sessions to acheive this but I
couldn't seem to make it work (probably I'm doing something wrong).
================================================== =========
I use the below code in each PHP script.
<?php
session_start();
header("Cache-control: private");
?>

Here's the code I use in "search_form.php"

$fields = $_GET["prefs"]; //prefs array from "preferences.html"

//If preferences are not set by user AND session variable fields not
set
if(!isset($_SESSION['fields']) && !isset($fields))
$_SESSION['fields'] = array("all"); // use default option "ALL"
else{
//If session variable fields not set
if(!isset($_SESSION['fields']))
$_SESSION['fields'] = $fields; //else assign user preferences.
}
print_r($_SESSION['fields']); //PRINT options
================================================== ============
The problem is, whenever I call the "search_form.php" from a link (Back
to New search) in search results page, the PRINT statement always
displays "all" - the default option - I mean, the first if statement is
always true. What could be the mistake in my code?

TIA
Singamsetty.

Oct 14 '05 #1
1 1368
Hemanth wrote:
I'm trying to create a script that searches a few database tables based
on the search text and user search preferences. I created a PHP script
(search_form.php) that displays textbox, a search button and a
preferences link. The preferences link opens a popup (preferences.html)
and lists search categories (checkboxes - with search only in column1,
column2 etc. or ALL) and a select button. If the users specify the
preferences I call search_form.php with an "prefs[]" array as argument.
In search_form.php I invoke another script (search.php) - to display
search results - based on user preferences and search text entered.

My question is, how do I make the script remember these preferences and
search text (if user selects links like "Back to Search Results" or
"Back to new search" in other pages) till he closes the existing
window. I understand I can use PHP sessions to acheive this but I

<snip>

FWIW, I would say that your design is not user friendly. What I
would prefer is that the provision to store the Preferences in DB in
separate page and in the search page again showing the "remembered
preferences" so that the user can override previous preferences in the
search page for the current search alone. Use of session for search
will break usability, IMHO. This is what is I'm witnessing in mantis
bts.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Oct 15 '05 #2

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

Similar topics

13
by: jing_li | last post by:
Hi, you all, I am a newbee for php and I need your help. One of my coworker and I are both developing a webpage for our project using php. We have a copy of the same files in different location...
1
by: ben | last post by:
I have a Session table: Username Type ------------------ bob private bob private sally private bob duet And I have an event table
28
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical...
12
by: D. Shane Fowlkes | last post by:
This is a repost (pasted below). Since my original post, I've double checked the system clock and set all IIS Session Timeout values to 10 minutes. Still ...the problem occurs. I've also...
17
by: jensen bredal | last post by:
Hello, i'm struggling with a somehow badly understood session scenario. I provide acces to my pages based on form authentication using Session cookies. Som of my pages are supposed to be...
1
by: Michael D. Reed | last post by:
I am using the help class to display a simple help file. I generated the help file using Word and saving it as a single page Web page (.mht extension). I show the help file with the following...
3
Atli
by: Atli | last post by:
Introduction: Sessions are one of the simplest and more powerful tools in a web developers arsenal. This tool is invaluable in dynamic web page development and it is one of those things every...
1
by: sajaisosa | last post by:
Hey there I've been following through the book "Beginning Python from Novice to Professional", and I have learned a great deal. At the moment, I am trying to expand upon the chatroom project near...
8
by: Eddie | last post by:
I am having difficulty in setting variables in a session, and then accessing those variables throughout the web pages that they click on. After having them set a user name and password,...
8
by: Dave | last post by:
Hopefully this is an easy question for those with more experience. I have two separate programs that I want to use together on a website Program A starts first and calls session_start(). ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.