473,788 Members | 2,988 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ph p) that displays textbox, a search button and a
preferences link. The preferences link opens a popup (preferences.ht ml)
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.ph p"

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

//If preferences are not set by user AND session variable fields not
set
if(!isset($_SES SION['fields']) && !isset($fields) )
$_SESSION['fields'] = array("all"); // use default option "ALL"
else{
//If session variable fields not set
if(!isset($_SES SION['fields']))
$_SESSION['fields'] = $fields; //else assign user preferences.
}
print_r($_SESSI ON['fields']); //PRINT options
=============== =============== =============== =============== ==
The problem is, whenever I call the "search_form.ph p" 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 1379
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.ph p) that displays textbox, a search button and a
preferences link. The preferences link opens a popup (preferences.ht ml)
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
12053
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 on the server (in our own accounts on the same machine). When I am testing both versions of our program using the same browser (IE on Windows or Konqueror on Linux) the session variables will mix up and only the latest selection or options will...
1
2027
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
3307
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 make-believe challenge in order to avoid confusing the issue further. Suppose I was hosting a dinner and I wanted to invite exactly 12 guests from my neighborhood. I'm really picky about that... I have 12 chairs besides my own, and I want them all...
12
2295
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 installed Deep Metrix Live Stats 6.2 XPS just to make sure nothing really strange was going on was going on. Still....the sessions only increment...or should I say my counter in my asax file.... and never goes down. If it matters, this machine is...
17
5217
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 running continuously and refreshing once an hour. I there set timeout= 61 in <sessionState section and on my page it says <meta http-equiv="refresh" content="3600">. I also set timeout=120 in the <forms section of web.config to make sure
1
1978
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 statement. Help.ShowHelp(Parent:=Me, url:=Me.HELP_URL_PRE & Me.myWorker.HelpFile) How do I get it to go away when the program exits? Now when I quit the program that I called it form the help file is sill displayed. Is there a way to get a handle...
3
28323
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 developer needs to know how to use. This article explains the basics of PHP Sessions. Assumptions: Basic PHP knowledge is required (variables, arrays and such) HTML Forms. What are Sessions? Sessions are a way of storing data. When developing...
1
1815
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 the end of this book. My problem, is that I can't get my head around how to allow the users to add new rooms. At the moment, there is only one room. My first thought on how to do this was instantiating objects from the main room class, using the...
8
3025
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, successfully authenticating against Active Directory, I send them from the login.php page to the index.php page. But when I get to the index.php page, the session ID is visible, but the session variables and values are not. Can you help me out? Also,...
8
1841
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(). Program B is started by the user clicking on a link and it also calls session_start(). The session started by program B blows away the session started by program
0
9655
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10172
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...

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.