Go Back   SitePoint Forums > Forum Index > Program Your Site > PHP
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Jul 16, 2005, 00:42   #1
ranjitcool
SitePoint Addict
 
Join Date: Mar 2005
Posts: 273
sessions me ane:((

hi guys

its always, with me(

i always get so darn confused with sessions

now the problem is

i have a check box form from where user can choose more than 1 option (well thats what check box is for)

now i need to store them , all the vlaues that the user chooses in a session array and retrieve them


i had a dim idea of it
and tried hard

but cundt get it

list.html --->input.php (stores in array sessions)--->output.php(retrieves froms essions)

please help guys

and ya i dont have gve unique name to sessions right?? do tell me on that coz the system which i wanna make might use like more than a 1000 users

thanx guys
counting on mgolfe
ranjitcool is offline   Reply With Quote
Old Jul 16, 2005, 04:06   #2
Opserty
SitePoint Zealot
 
Join Date: May 2005
Location: Birmingham UK
Posts: 148
Are you sure you need to use sessions? What does input.php do with the data, can you not just pass it straight on to output.php?
Opserty is offline   Reply With Quote
Old Jul 16, 2005, 10:23   #3
ranjitcool
SitePoint Addict
 
Join Date: Mar 2005
Posts: 273
no ddue

hey dude , i need to save them in sessions so that i use another script to give it to flash audio player..


please help me out!
ranjitcool is offline   Reply With Quote
Old Jul 16, 2005, 13:04   #4
coo_t2
Non-Member
 
coo_t2's Avatar
 
Join Date: Feb 2003
Location: Dog Street
Posts: 1,823
Quote:
Originally Posted by ranjitcool

i have a check box form from where user can choose more than 1 option (well thats what check box is for)
Are you sure you don't mean a multiple select box?

If it's just a check box you do something like this:

PHP Code:

   <?php
   session_start
();
   
   
$_SESSION['checkbox_name'] = $_POST['checkbox_name'];
That will store an empty value if it's not checked and the string "on" if it is checked, unless you give the "value" attribute of the checkbox element a value, then that string will show up if checked.

For a multiple select do something like this:

The code for the form:
PHP Code:

   
    
<select multiple name="multipleSelect[]">
     <
option value="option one">option one</option>
     <
option value="option two">option two</option>
    </
select>
The code that handles the form:
PHP Code:

   <?php
   session_start
();
   
     
$_SESSION['multiple_select'] = $_POST['multipleSelect'];
This is assuming you're using the "post" method in your forms. The multiple select form element will be posted as an array, so you can just store the array in a session variable.
coo_t2 is offline   Reply With Quote
Old Jul 16, 2005, 23:33   #5
ranjitcool
SitePoint Addict
 
Join Date: Mar 2005
Posts: 273
hey thanx....but how do i retreive the values stored in the sessions!
ranjitcool is offline   Reply With Quote
Old Jul 17, 2005, 03:30   #6
Opserty
SitePoint Zealot
 
Join Date: May 2005
Location: Birmingham UK
Posts: 148
PHP Code:

<?php

   session_start
();
   
     
$multiple_select = $_SESSION['multiple_select'];
Opserty is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 20:27.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved