[PHP-DB] session variables when accessing the same page

2003-10-11 Thread Andy Cantrell
Working with storing and reusing session variables.
If I use t1.php to generate a form, and the form
calls t2.php, the session vars are available.
If upgrade t1.php to recognize if it is the first
time it has been called versus the second time
e.g.
   if (isset($some_session_var)) {
  generate_second_page();
   } else {
  # set $some_sesson_var in the function
  # and use session_register() for that var.
  # I have verified that I'm using "global $some_session_var"
  # under here as well as generate_second_page().
  generate_initial_page();
   };
Under this scenario, I'm unable to find any session
vars.  That is, "$some_session_var" is never set the
second time I call t1.php.  If I change the  tag
to call t2.php that has the code for 'generate_second_page()'
than all seems to work ok.  Am I missing something?
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Session variables

2003-04-06 Thread Paul Burney
on 4/6/03 10:39 PM, Alexa Kirk at [EMAIL PROTECTED] appended the following bits
to my mbox:

> I am using session variables throughout an application, and every time I
> try to log in as someone else after the first time I've logged in, it
> uses the userid of the first person that logged in. I know the session
> has to be destroyed or something, so I wanted to make a logoff page, but
> it is not working. I'm getting an Internal Server Error.
> Here is my code for logoff.php:

This is pretty off-topic for the PHP-DB list.  It should be on PHP-General
instead.

If I recall correctly, the actual session files aren't deleted on the server
when you call session_destroy(); They hang around until garbage collection
kicks in. The user's cookie is also not deleted so they come back with the
same session next time if the browser isn't quit first.  One solution is to
manually unset the session variables as well.  I've done things like this:

session_start();
session_unregister('this_password');
session_unregister('this_username');
session_unset();
session_destroy();

According to php.net, you should also do:

$_SESSION = array();

Before the calls to unset and destroy.

See the comments on this page for a bunch more information:



HTH.

Sincerely,

Paul Burney






-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Session variables

2003-04-06 Thread Alexa Kirk
I am using session variables throughout an application, and every time I
try to log in as someone else after the first time I've logged in, it
uses the userid of the first person that logged in. I know the session
has to be destroyed or something, so I wanted to make a logoff page, but
it is not working. I'm getting an Internal Server Error.
Here is my code for logoff.php:

 
Does anyone know what I am doing wrong?
 
Thank you,
Alexa


RE: [PHP-DB] Session variables when global variables switched off [Sorry, firs t message accidentally fired off to quickly ]

2003-02-18 Thread Clarkson, Nick

Try changing your code to 

if ($_SESSION['verified'] != "yes"){

I think that's the problem

Nick



-Original Message-
From: Baumgartner Jeffrey [mailto:[EMAIL PROTECTED]]
Sent: 18 February 2003 11:20
To: '[EMAIL PROTECTED]'
Subject: [PHP-DB] Session variables when global variables switched off
[Sorry, firs t message accidentally fired off to quickly ]


[sorry for the incomplete posting of a couple moments ago. I hit ctl
something or other and outlook fired off the e-mail against my wishes!]

I am making a section on a web site which requires that visitors log-in.
Log-in, password, etc are in an MySQL table. I am using (via a web host) PHP
4.2.2 with global variables turned off. Until now, I have worked with a
different host in which global variables were switched on.

The way it works
The user logs in at index.php. When she does so successfully, index.php
returns a menu of links. However, if she clicks on any of those links, which
are different pages, she gets a please log-in first message because each
page includes...

if ($_SESSION['verified'] <> "yes"){
echo "Please log in first";
exit();
}

Returning to index.php requires a log-in again.

So, it seems the session variable is not being sent being sent between
pages, although it works within the same page. I expect I am missing
something obvious. I've made this kind of thing work with global variables
on - so I assume I am misunderstanding something related to lack of global
variables. 

I use 

session_start(); 

at the top of all pages and  

session_register($_SESSION['okbabe']); 

on index.php.

Your enlightenment will be highly appreciated.

Jeffrey Baumgartner


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


This private and confidential e-mail has been sent to you by Egg.
The Egg group of companies includes Egg Banking plc
(registered no. 2999842), Egg Financial Products Ltd (registered
no. 3319027) and Egg Investments Ltd (registered no. 3403963) which
carries out investment business on behalf of Egg and is regulated
by the Financial Services Authority.  
Registered in England and Wales. Registered offices: 1 Waterhouse Square,
138-142 Holborn, London EC1N 2NA.
If you are not the intended recipient of this e-mail and have
received it in error, please notify the sender by replying with
'received in error' as the subject and then delete it from your
mailbox.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Session variables when global variables switched off [Sorry, first message accidentally fired off to quickly ]

2003-02-18 Thread Rich Gray
Hi Jeff

Don't use session_register() just use the $_SESSION superglobal as you would
use any other array.

So does this work?



http://mysite/index.php');
exit();
}
?>

HTH
Rich
> -Original Message-
> From: Baumgartner Jeffrey [mailto:[EMAIL PROTECTED]]
> Sent: 18 February 2003 11:20
> To: '[EMAIL PROTECTED]'
> Subject: [PHP-DB] Session variables when global variables switched off
> [Sorry, first message accidentally fired off to quickly ]
>
>
> [sorry for the incomplete posting of a couple moments ago. I hit ctl
> something or other and outlook fired off the e-mail against my wishes!]
>
> I am making a section on a web site which requires that visitors log-in.
> Log-in, password, etc are in an MySQL table. I am using (via a
> web host) PHP
> 4.2.2 with global variables turned off. Until now, I have worked with a
> different host in which global variables were switched on.
>
> The way it works
> The user logs in at index.php. When she does so successfully, index.php
> returns a menu of links. However, if she clicks on any of those
> links, which
> are different pages, she gets a please log-in first message because each
> page includes...
>
> if ($_SESSION['verified'] <> "yes"){
> echo "Please log in first";
> exit();
> }
>
> Returning to index.php requires a log-in again.
>
> So, it seems the session variable is not being sent being sent between
> pages, although it works within the same page. I expect I am missing
> something obvious. I've made this kind of thing work with global variables
> on - so I assume I am misunderstanding something related to lack of global
> variables.
>
> I use
>
> session_start();
>
> at the top of all pages and
>
> session_register($_SESSION['okbabe']);
>
> on index.php.
>
> Your enlightenment will be highly appreciated.
>
> Jeffrey Baumgartner
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Session variables when global variables switched off [Sorry, first message accidentally fired off to quickly ]

2003-02-18 Thread Baumgartner Jeffrey
[sorry for the incomplete posting of a couple moments ago. I hit ctl
something or other and outlook fired off the e-mail against my wishes!]

I am making a section on a web site which requires that visitors log-in.
Log-in, password, etc are in an MySQL table. I am using (via a web host) PHP
4.2.2 with global variables turned off. Until now, I have worked with a
different host in which global variables were switched on.

The way it works
The user logs in at index.php. When she does so successfully, index.php
returns a menu of links. However, if she clicks on any of those links, which
are different pages, she gets a please log-in first message because each
page includes...

if ($_SESSION['verified'] <> "yes"){
echo "Please log in first";
exit();
}

Returning to index.php requires a log-in again.

So, it seems the session variable is not being sent being sent between
pages, although it works within the same page. I expect I am missing
something obvious. I've made this kind of thing work with global variables
on - so I assume I am misunderstanding something related to lack of global
variables. 

I use 

session_start(); 

at the top of all pages and  

session_register($_SESSION['okbabe']); 

on index.php.

Your enlightenment will be highly appreciated.

Jeffrey Baumgartner


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Session variables when global variables switched off

2003-02-18 Thread Baumgartner Jeffrey
I am making a section on a web site which requires that visitors log-in.
Log-in, password, etc are in an MySQL table. I am using (via a web host) PHP
4.2.2 with global variables turned off. Until now, I have worked with a
different host in which global variables were switched on.

The way it works
The user logs in at index.php. When she does so successfully, index.php
returns a menu of links. However, if she clicks on any of those links, which
are different pages, she gets a please log-in first message 




eBusiness Consultant - ITP Europe
http://www.itp-europe.com
[EMAIL PROTECTED]
+32 2 721 51 00


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] session variables

2002-11-07 Thread Maxim Maletsky

"kevin myers" <[EMAIL PROTECTED]> wrote... :

> I have a question:
> I have a site, http://www.darkrpg.ionichost.com, and 
> htp://www.mail.ionichost.com.  I'm trying to find a way of passing the 
> session varible from darkrpg to mail that way they need not log in again.  
> Is it possiable with out cookies?

Are they on the same server? If yes, then you can still share the data
within session if you pass session ID in get while linking between the
sites. It is up to your logic how to do so. Though, i discourage you
doing it as this is a HUGE security hole.

> And another question i have is on 
> http://www.darkrpg.ionichost.com/login/,  i have it set up where after you 
> suvmit your log in information it displays you session information.  Every 
> time I log in it says that the mysql result is not valid yet it still logs 
> me and my user in.  Is there any way to remove this message from the screen? 
>   Is it possiable that it is the way i have my query set up?

It can be mySQL's bug. To get rid of that error just add at-mark (@)
infront of the function call:

@mysql_connect(...

or whatever


--
Maxim Maletsky
[EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] session variables

2002-11-07 Thread kevin myers
I have a question:
I have a site, http://www.darkrpg.ionichost.com, and 
htp://www.mail.ionichost.com.  I'm trying to find a way of passing the 
session varible from darkrpg to mail that way they need not log in again.  
Is it possiable with out cookies?  And another question i have is on 
http://www.darkrpg.ionichost.com/login/,  i have it set up where after you 
suvmit your log in information it displays you session information.  Every 
time I log in it says that the mysql result is not valid yet it still logs 
me and my user in.  Is there any way to remove this message from the screen? 
 Is it possiable that it is the way i have my query set up?
thanks
Kevin Myers

_
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Session variables and arrays

2002-10-30 Thread Peter Beckman
After a little more research I found out strlen will return 5 for a real
array too, so throw that out.  However, since gettype prints a string not
an array, I just don't know.  print_r prints the array, but you can iterate
through it.

Do you do this before your loop?

reset($_SESSION['categories']);

print_r($var) will set the pointer to the end of the array, so you have to
reset it to the beginning before you iterate through it again.

Maybe this is the problem?

Peter

On Wed, 30 Oct 2002, Ryan Neudorf wrote:

> Here are the results:
>
> is_array():
> gettype():string
> strlen():5
>
> > -Original Message-
> > From: Peter Beckman [mailto:beckman@;purplecow.com]
> > Sent: Wednesday, October 30, 2002 8:57 AM
> > To: Ryan Neudorf
> > Cc: [EMAIL PROTECTED]
> > Subject: RE: [PHP-DB] Session variables and arrays
> >
> >
> > On Wed, 30 Oct 2002, Ryan Neudorf wrote:
> >
> > > Ok. The categories are coming from checkboxes, e.g.:
> > >  > />Accountant > > />
> > >
> > > Which then are handled by a $cgi class dealy and handed to the
> > > $_SESSION['categories'] variable before being forwarded to the next
> > > step. I was thinking that the problem might be with the
> > $cgi object,
> > > but when I print_r($_SESSION['categories']) it shows the
> > contents of
> > > the array.
> > >
> > > Anyways, I did the print ":::{$_SESSION['categories']}:::"; and got
> > > :::Array:::
> >
> >  Try this after that print:
> >
> >  print is_array($_SESSION['categories']);
> >
> >  You should get a 1 -- if you don't, try this:
> >
> >  print gettype($_SESSION['categories']);
> >
> >  You should get "array" but if you don't, there is something
> > strange going  on!  If you get "string" though, do this:
> >
> >  print strlen($_SESSION['categories']);
> >
> >  If you get "5", then the variable might be a string with the
> > contents  being the word "Array".  Pretty doubtful, but we're
> > being thorough here.
> >
> > Peter
> >
> > > Hmph
> > >
> > > - Ryan
> > >
> > > > -Original Message-
> > > > From: Peter Beckman [mailto:beckman@;purplecow.com]
> > > > Sent: Tuesday, October 29, 2002 9:59 PM
> > > > To: Ryan Neudorf
> > > > Cc: [EMAIL PROTECTED]
> > > > Subject: Re: [PHP-DB] Session variables and arrays
> > > >
> > > >
> > > > Well, can't say I see the same problem:
> > > >
> > > >  > > > $_SESSION['foo'] = array("hi"=>"bye");
> > > >
> > > > print_r($_SESSION['foo']);
> > > > echo "\n\n";
> > > > print is_array($_SESSION['foo']);
> > > >
> > > > Outputs:
> > > > X-Powered-By: PHP/4.2.2
> > > > Content-type: text/html
> > > >
> > > > Array
> > > > (
> > > > [hi] => bye
> > > > )
> > > > 1
> > > >
> > > > Which is what I'd expect it to show.
> > > >
> > > > Now how did you assign categories?
> > > >
> > > > Maybe the var is a scalar and is actually "Array (\n  [0]
> > => '1';\n
> > > > [1] => '12';" and you are confused.o
> > > >
> > > > If you are saying:
> > > >
> > > > $_SESSION['categories'] = "Array (
> > > > [0] = '1';
> > > > ";
> > > >
> > > > Then it IS a scalar.  Try this:
> > > >
> > > > print ":::{$_SESSION['categories']}:::";
> > > >
> > > > If you get this:
> > > >
> > > > :::Array:::
> > > >
> > > > Then I have no clue what the problem is
> > > >
> > > > If you don't get that, then we know what your problem is.
> > > >
> > > > Peter
> > > >
> > > > On Tue, 29 Oct 2002, Ryan Neudorf wrote:
> > > >
> > > > > I'm having a problem with session variables and arrays. I'm
> > > > > building a multi step sign up form and I need to store all the
> > > > > variable until the final step, when th

RE: [PHP-DB] Session variables and arrays

2002-10-30 Thread Ryan Neudorf
Here are the results:

is_array():
gettype():string
strlen():5

> -Original Message-
> From: Peter Beckman [mailto:beckman@;purplecow.com] 
> Sent: Wednesday, October 30, 2002 8:57 AM
> To: Ryan Neudorf
> Cc: [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] Session variables and arrays
> 
> 
> On Wed, 30 Oct 2002, Ryan Neudorf wrote:
> 
> > Ok. The categories are coming from checkboxes, e.g.:
> >  />Accountant > />
> >
> > Which then are handled by a $cgi class dealy and handed to the 
> > $_SESSION['categories'] variable before being forwarded to the next 
> > step. I was thinking that the problem might be with the 
> $cgi object, 
> > but when I print_r($_SESSION['categories']) it shows the 
> contents of 
> > the array.
> >
> > Anyways, I did the print ":::{$_SESSION['categories']}:::"; and got
> > :::Array:::
> 
>  Try this after that print:
> 
>  print is_array($_SESSION['categories']);
> 
>  You should get a 1 -- if you don't, try this:
> 
>  print gettype($_SESSION['categories']);
> 
>  You should get "array" but if you don't, there is something 
> strange going  on!  If you get "string" though, do this:
> 
>  print strlen($_SESSION['categories']);
> 
>  If you get "5", then the variable might be a string with the 
> contents  being the word "Array".  Pretty doubtful, but we're 
> being thorough here.
> 
> Peter
> 
> > Hmph
> >
> > - Ryan
> >
> > > -Original Message-
> > > From: Peter Beckman [mailto:beckman@;purplecow.com]
> > > Sent: Tuesday, October 29, 2002 9:59 PM
> > > To: Ryan Neudorf
> > > Cc: [EMAIL PROTECTED]
> > > Subject: Re: [PHP-DB] Session variables and arrays
> > >
> > >
> > > Well, can't say I see the same problem:
> > >
> > >  > > $_SESSION['foo'] = array("hi"=>"bye");
> > >
> > > print_r($_SESSION['foo']);
> > > echo "\n\n";
> > > print is_array($_SESSION['foo']);
> > >
> > > Outputs:
> > > X-Powered-By: PHP/4.2.2
> > > Content-type: text/html
> > >
> > > Array
> > > (
> > > [hi] => bye
> > > )
> > > 1
> > >
> > > Which is what I'd expect it to show.
> > >
> > > Now how did you assign categories?
> > >
> > > Maybe the var is a scalar and is actually "Array (\n  [0] 
> => '1';\n  
> > > [1] => '12';" and you are confused.o
> > >
> > > If you are saying:
> > >
> > > $_SESSION['categories'] = "Array (
> > > [0] = '1';
> > > ";
> > >
> > > Then it IS a scalar.  Try this:
> > >
> > > print ":::{$_SESSION['categories']}:::";
> > >
> > > If you get this:
> > >
> > > :::Array:::
> > >
> > > Then I have no clue what the problem is
> > >
> > > If you don't get that, then we know what your problem is.
> > >
> > > Peter
> > >
> > > On Tue, 29 Oct 2002, Ryan Neudorf wrote:
> > >
> > > > I'm having a problem with session variables and arrays. I'm 
> > > > building a multi step sign up form and I need to store all the 
> > > > variable until the final step, when they are inputed to a
> > > database. I
> > > > thought the best way to do this would be to store the 
> contents for 
> > > > $HTTP_POST_VARS in session variables. This works fine for
> > > everything
> > > > except for my array of checkboxes.
> > > >
> > > > When I do a print_r($_SESSION) it displays the 
> following for the 
> > > > sessionvariable assigned to the checkboxes: 
> [categories] => Array (
> > > > [0] => '1';
> > > > [1] => '12';
> > > > ... Etc ...
> > > >
> > > > But when I run any sort of array function (is_array, 
> foreach) on 
> > > > $_SESSION['categories'] it appears that it is a scalar, not
> > > an array.
> > > >
> > > > Any ideas?
> > > >
> > > > - Ryan
> > > >
> > > >
> > > > --
> > > > PHP Database Mailing List (http://www.php.net/)
> > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > >
> > >
> > > --
> > > -
> > > Peter BeckmanSystems Engineer, Fairfax Cable
> > > Access Corporation
> > > [EMAIL PROTECTED]
> > > http://www.purplecow.com/
> > >
> > > --
> > > -
> > >
> > >
> > > --
> > > PHP Database Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 
> --
> -
> Peter BeckmanSystems Engineer, Fairfax Cable 
> Access Corporation
> [EMAIL PROTECTED] 
> http://www.purplecow.com/
> 
> --
> -
> 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Session variables and arrays

2002-10-30 Thread Peter Beckman
On Wed, 30 Oct 2002, Ryan Neudorf wrote:

> Ok. The categories are coming from checkboxes, e.g.:
> Accountant
>
> Which then are handled by a $cgi class dealy and handed to the
> $_SESSION['categories'] variable before being forwarded to the next
> step. I was thinking that the problem might be with the $cgi object, but
> when I print_r($_SESSION['categories']) it shows the contents of the
> array.
>
> Anyways, I did the print ":::{$_SESSION['categories']}:::"; and got
> :::Array:::

 Try this after that print:

 print is_array($_SESSION['categories']);

 You should get a 1 -- if you don't, try this:

 print gettype($_SESSION['categories']);

 You should get "array" but if you don't, there is something strange going
 on!  If you get "string" though, do this:

 print strlen($_SESSION['categories']);

 If you get "5", then the variable might be a string with the contents
 being the word "Array".  Pretty doubtful, but we're being thorough here.

Peter

> Hmph
>
> - Ryan
>
> > -Original Message-----
> > From: Peter Beckman [mailto:beckman@;purplecow.com]
> > Sent: Tuesday, October 29, 2002 9:59 PM
> > To: Ryan Neudorf
> > Cc: [EMAIL PROTECTED]
> > Subject: Re: [PHP-DB] Session variables and arrays
> >
> >
> > Well, can't say I see the same problem:
> >
> >  > $_SESSION['foo'] = array("hi"=>"bye");
> >
> > print_r($_SESSION['foo']);
> > echo "\n\n";
> > print is_array($_SESSION['foo']);
> >
> > Outputs:
> > X-Powered-By: PHP/4.2.2
> > Content-type: text/html
> >
> > Array
> > (
> > [hi] => bye
> > )
> > 1
> >
> > Which is what I'd expect it to show.
> >
> > Now how did you assign categories?
> >
> > Maybe the var is a scalar and is actually "Array (\n  [0] =>
> > '1';\n  [1] => '12';" and you are confused.o
> >
> > If you are saying:
> >
> > $_SESSION['categories'] = "Array (
> > [0] = '1';
> > ";
> >
> > Then it IS a scalar.  Try this:
> >
> > print ":::{$_SESSION['categories']}:::";
> >
> > If you get this:
> >
> > :::Array:::
> >
> > Then I have no clue what the problem is
> >
> > If you don't get that, then we know what your problem is.
> >
> > Peter
> >
> > On Tue, 29 Oct 2002, Ryan Neudorf wrote:
> >
> > > I'm having a problem with session variables and arrays.
> > > I'm building a multi step sign up form and I need to store all the
> > > variable until the final step, when they are inputed to a
> > database. I
> > > thought the best way to do this would be to store the contents for
> > > $HTTP_POST_VARS in session variables. This works fine for
> > everything
> > > except for my array of checkboxes.
> > >
> > > When I do a print_r($_SESSION) it displays the following for the
> > > sessionvariable assigned to the checkboxes: [categories] => Array (
> > >   [0] => '1';
> > >   [1] => '12';
> > > ... Etc ...
> > >
> > > But when I run any sort of array function (is_array, foreach) on
> > > $_SESSION['categories'] it appears that it is a scalar, not
> > an array.
> > >
> > > Any ideas?
> > >
> > > - Ryan
> > >
> > >
> > > --
> > > PHP Database Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >
> > --
> > -
> > Peter BeckmanSystems Engineer, Fairfax Cable
> > Access Corporation
> > [EMAIL PROTECTED]
> > http://www.purplecow.com/
> >
> > --
> > -
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

---
Peter BeckmanSystems Engineer, Fairfax Cable Access Corporation
[EMAIL PROTECTED] http://www.purplecow.com/
---


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Session variables and arrays

2002-10-29 Thread Ryan Neudorf
Ok. The categories are coming from checkboxes, e.g.:
Accountant

Which then are handled by a $cgi class dealy and handed to the
$_SESSION['categories'] variable before being forwarded to the next
step. I was thinking that the problem might be with the $cgi object, but
when I print_r($_SESSION['categories']) it shows the contents of the
array.

Anyways, I did the print ":::{$_SESSION['categories']}:::"; and got 
:::Array:::

Hmph

- Ryan

> -Original Message-
> From: Peter Beckman [mailto:beckman@;purplecow.com] 
> Sent: Tuesday, October 29, 2002 9:59 PM
> To: Ryan Neudorf
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] Session variables and arrays
> 
> 
> Well, can't say I see the same problem:
> 
>  $_SESSION['foo'] = array("hi"=>"bye");
> 
> print_r($_SESSION['foo']);
> echo "\n\n";
> print is_array($_SESSION['foo']);
> 
> Outputs:
> X-Powered-By: PHP/4.2.2
> Content-type: text/html
> 
> Array
> (
> [hi] => bye
> )
> 1
> 
> Which is what I'd expect it to show.
> 
> Now how did you assign categories?
> 
> Maybe the var is a scalar and is actually "Array (\n  [0] => 
> '1';\n  [1] => '12';" and you are confused.o
> 
> If you are saying:
> 
> $_SESSION['categories'] = "Array (
> [0] = '1';
> ";
> 
> Then it IS a scalar.  Try this:
> 
> print ":::{$_SESSION['categories']}:::";
> 
> If you get this:
> 
> :::Array:::
> 
> Then I have no clue what the problem is
> 
> If you don't get that, then we know what your problem is.
> 
> Peter
> 
> On Tue, 29 Oct 2002, Ryan Neudorf wrote:
> 
> > I'm having a problem with session variables and arrays.
> > I'm building a multi step sign up form and I need to store all the 
> > variable until the final step, when they are inputed to a 
> database. I 
> > thought the best way to do this would be to store the contents for 
> > $HTTP_POST_VARS in session variables. This works fine for 
> everything 
> > except for my array of checkboxes.
> >
> > When I do a print_r($_SESSION) it displays the following for the 
> > sessionvariable assigned to the checkboxes: [categories] => Array (
> > [0] => '1';
> > [1] => '12';
> > ... Etc ...
> >
> > But when I run any sort of array function (is_array, foreach) on 
> > $_SESSION['categories'] it appears that it is a scalar, not 
> an array.
> >
> > Any ideas?
> >
> > - Ryan
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 
> --
> -
> Peter BeckmanSystems Engineer, Fairfax Cable 
> Access Corporation
> [EMAIL PROTECTED] 
> http://www.purplecow.com/
> 
> --
> -
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Session variables and arrays

2002-10-29 Thread Peter Beckman
Well, can't say I see the same problem:

"bye");

print_r($_SESSION['foo']);
echo "\n\n";
print is_array($_SESSION['foo']);

Outputs:
X-Powered-By: PHP/4.2.2
Content-type: text/html

Array
(
[hi] => bye
)
1

Which is what I'd expect it to show.

Now how did you assign categories?

Maybe the var is a scalar and is actually "Array (\n  [0] => '1';\n  [1] =>
'12';" and you are confused.o

If you are saying:

$_SESSION['categories'] = "Array (
[0] = '1';
";

Then it IS a scalar.  Try this:

print ":::{$_SESSION['categories']}:::";

If you get this:

:::Array:::

Then I have no clue what the problem is

If you don't get that, then we know what your problem is.

Peter

On Tue, 29 Oct 2002, Ryan Neudorf wrote:

> I'm having a problem with session variables and arrays.
> I'm building a multi step sign up form and I need to store all the
> variable until the final step, when they are inputed to a database. I
> thought the best way to do this would be to store the contents for
> $HTTP_POST_VARS in session variables. This works fine for everything
> except for my array of checkboxes.
>
> When I do a print_r($_SESSION) it displays the following for the
> sessionvariable assigned to the checkboxes:
> [categories] => Array (
>   [0] => '1';
>   [1] => '12';
> ... Etc ...
>
> But when I run any sort of array function (is_array, foreach) on
> $_SESSION['categories'] it appears that it is a scalar, not an array.
>
> Any ideas?
>
> - Ryan
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

---
Peter BeckmanSystems Engineer, Fairfax Cable Access Corporation
[EMAIL PROTECTED] http://www.purplecow.com/
---


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Session variables and arrays

2002-10-29 Thread Ryan Neudorf
I'm having a problem with session variables and arrays.
I'm building a multi step sign up form and I need to store all the
variable until the final step, when they are inputed to a database. I
thought the best way to do this would be to store the contents for
$HTTP_POST_VARS in session variables. This works fine for everything
except for my array of checkboxes. 

When I do a print_r($_SESSION) it displays the following for the
sessionvariable assigned to the checkboxes:
[categories] => Array (
[0] => '1';
[1] => '12';
... Etc ...

But when I run any sort of array function (is_array, foreach) on
$_SESSION['categories'] it appears that it is a scalar, not an array.

Any ideas?

- Ryan


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] session variables and form

2002-09-19 Thread Smita Manohar

hello all..

in my site, where im using phpscript, some users are allowed to del/modify 
contents of the database. for this they have been provided login name and 
password, after user loggs into the secure area, session starts. since here, 
user can modify/del contents of database, i needed to use many forms.  
arrays are used to store the checkbox, textbox values which user wants to 
modify. since these values are submitted thru forms in session, when 
browsers back button is pressed, it forces to press refresh button, to 
retrieve the values.

can anyone help me to know how to pass variables to other pages in session 
using FORM POST

or is it efficient to use session variables for all these values submited 
via FORM??

smita



_
Chat with friends online, try MSN Messenger: http://messenger.msn.com


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] session variables across several pages

2002-05-15 Thread Terry Romine

huh.. seems to work, now.

I do the following:
 session_start();
 session_register("form_data");
 if($doAction) {
 switch($doAction) {
 case "Save Information":
 // save data in cookies
 $HTTP_SESSION_VARS['form_data'] = 
array($name,$employer,$e_address);
...

and on the thanks page:
session_start();
 session_register("form_data");
list($name,$employer,$e_address) = $form_data;

and it displays the correct data now.

S the trick seems to be to not use the same var names.

Ok. I got it.

Thanks!!

On Wednesday, May 15, 2002, at 11:01  AM, matt stewart wrote:

> don't think you can have an array as a session variable, you'd have to 
> set
> it as character delimited string or something.
>
Terry Romine
Web Developer
JumpInteractive.com


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] session variables across several pages

2002-05-15 Thread matt stewart

i would consider trying changing the variable names - so the field  on the
form would be called "address", therefore the variable passed through would
be $address, and then have the session variable called "sess_address" or
something like that, and then do  

$HTTP_SESSION_VARS['sess_address']=$address;

see if that makes any difference?

-Original Message-
From: Terry Romine [mailto:[EMAIL PROTECTED]]
Sent: 15 May 2002 16:40
To: matt stewart
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] session variables across several pages 


This is freaky.

If I change the  I can see the e_address coming in 
correctly, but it gets changed back to old value -- by the 
session_register('e_address')??

should I have something along the line of
if(!$e_address) register_session('e_address');
???

On Wednesday, May 15, 2002, at 09:57  AM, matt stewart wrote:

> You need to look up $HTTP_SESSION_VARS['name']  - that's how to change 
> the
> variables when they are already set..
> i think most people have this problem when they first use sessions!
>
Terry Romine
Web Developer
JumpInteractive.com

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] session variables across several pages

2002-05-15 Thread Terry Romine

This is freaky.

If I change the  I can see the e_address coming in 
correctly, but it gets changed back to old value -- by the 
session_register('e_address')??

should I have something along the line of
if(!$e_address) register_session('e_address');
???

On Wednesday, May 15, 2002, at 09:57  AM, matt stewart wrote:

> You need to look up $HTTP_SESSION_VARS['name']  - that's how to change 
> the
> variables when they are already set..
> i think most people have this problem when they first use sessions!
>
Terry Romine
Web Developer
JumpInteractive.com


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] session variables across several pages

2002-05-15 Thread Terry Romine

I believe you.. I added
 $HTTP_SESSION_VARS['e_address'] = $e_address;
in my process form code and it's still not updating the var.

snippit from select_class.php where I have reference to $e_address:

 session_register("e_address");
...
 switch($doAction) {
 case "Save Information":
 // save data in cookies
 $HTTP_SESSION_VARS['e_address'] = $e_address;
die($e_address);
...
 
   
 Employer Address:
 
   
 
   
   
...

entering any new data does not replace the old data as the 
die($e_address) shows.

Whatsupwiththat???


On Wednesday, May 15, 2002, at 09:57  AM, matt stewart wrote:

> You need to look up $HTTP_SESSION_VARS['name']  - that's how to change 
> the
> variables when they are already set..
> i think most people have this problem when they first use sessions!
>
Terry Romine
Web Developer
JumpInteractive.com


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] session variables across several pages

2002-05-15 Thread matt stewart

You need to look up $HTTP_SESSION_VARS['name']  - that's how to change the
variables when they are already set..
i think most people have this problem when they first use sessions!

-Original Message-
From: Terry Romine [mailto:[EMAIL PROTECTED]]
Sent: 15 May 2002 15:49
To: [EMAIL PROTECTED]
Subject: [PHP-DB] session variables across several pages 


First, forgive me if this seems to be cross post -- but it does involve 
both PHP and MySQL.

My client requirements are:
 From their website, they display a list of classes. On registering for a 
class, the user is sent to a secure page that is hosted on a different 
secured server that does not have access to the client's MySQL database. 
I pass in the class info so the registration form can display
"Registering for class $title$start_date$cost"
The form then gathers name, address, etc including credit card info.

On submitting the form, the data is processed and a PGP email is sent 
out to the registar.

Then a thank you page is displayed and the user is forwarded back to the 
main site, where a second page is displayed allowing for either download 
of class materials or to return to the class list. This page is where I 
post the necessary info into the MySQL database.

So my dilemma -- I want to use session_register to capture the field 
info from the registration form and then read it back out on the website 
thank you page.

I have
 session_start();
 session_register("start_date");
 session_register("end_date");
 session_register("section");
 session_register("class");
 session_register("title");
 session_register("class_id");
 session_register("register_id");
 session_register("name");
 session_register("employer");
 session_register("e_address");
 session_register("e_city");
 session_register("e_state");
 session_register("e_zip");
at the beginning of the form page (select_class.php) and the thank you 
page on their website (thanks.php) where I post the info to MySQL.
The form includes inputs such as
 Name:
 
   
 

What happens is that old data shows up for name, and address (the only 
fields I have tested so far) regardless of what I enter in the form. I 
was under the impression that a registered variable is updated once the 
page is processed. If I am calling the same page (select_class.php) to 
process the form, does the data get reverted somehow? The data just 
doesn't seem to get updated to the form inputs.

What might I be missing?

Thanks in advance
Terry Romine
Web Developer
JumpInteractive.com


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] session variables across several pages

2002-05-15 Thread Terry Romine

First, forgive me if this seems to be cross post -- but it does involve 
both PHP and MySQL.

My client requirements are:
 From their website, they display a list of classes. On registering for a 
class, the user is sent to a secure page that is hosted on a different 
secured server that does not have access to the client's MySQL database. 
I pass in the class info so the registration form can display
"Registering for class $title$start_date$cost"
The form then gathers name, address, etc including credit card info.

On submitting the form, the data is processed and a PGP email is sent 
out to the registar.

Then a thank you page is displayed and the user is forwarded back to the 
main site, where a second page is displayed allowing for either download 
of class materials or to return to the class list. This page is where I 
post the necessary info into the MySQL database.

So my dilemma -- I want to use session_register to capture the field 
info from the registration form and then read it back out on the website 
thank you page.

I have
 session_start();
 session_register("start_date");
 session_register("end_date");
 session_register("section");
 session_register("class");
 session_register("title");
 session_register("class_id");
 session_register("register_id");
 session_register("name");
 session_register("employer");
 session_register("e_address");
 session_register("e_city");
 session_register("e_state");
 session_register("e_zip");
at the beginning of the form page (select_class.php) and the thank you 
page on their website (thanks.php) where I post the info to MySQL.
The form includes inputs such as
 Name:
 
   
 

What happens is that old data shows up for name, and address (the only 
fields I have tested so far) regardless of what I enter in the form. I 
was under the impression that a registered variable is updated once the 
page is processed. If I am calling the same page (select_class.php) to 
process the form, does the data get reverted somehow? The data just 
doesn't seem to get updated to the form inputs.

What might I be missing?

Thanks in advance
Terry Romine
Web Developer
JumpInteractive.com


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Session variables

2001-08-14 Thread Jason Wong

> When I run main.html, I get the following error message :
> Warning : Cannot send session cookie - headers already sent by (output
> started at /var/www/html/main.html: 10) in /var/www/html/main.html on
> line 11

> Where could I be wrong ?
>
> Raju

You must make sure that in pages where you use cookies that you do not have
any 'output' before the point where your cookies are set. Output includes
whitespace and blank lines.

Thus:

--- <- beginning of file


would be fine. But:


--- <- beginning of file



would not work because there is a blank line between the beginning of the
file and the place where you actually set the cookie -- session_start();.

This of course applies to any included files as well.

regards
--
Jason Wong
Gremlins Associates
www.gremlins.com.hk




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Session variables

2001-08-14 Thread CK Raju

I have compiled php-4.0.6 from source with --enable-track-vars and
--enable-trans-sid options (--with-mysql and --with-apxs).

I use RH7.1 and mysql-3.23.41.

In my /usr/local/test/connect.inc I use the following code


This file is invoked in all my script files. (The system works without
session variables.)

In my login file (main.html) I do a
");

print("");
print ("");
print("");
?>
--

In my login.html script file I start the links to other database
utilities, where the /usr/local/test/connect.inc file is invoked.

When I run main.html, I get the following error message :
Warning : Cannot send session cookie - headers already sent by (output
started at /var/www/html/main.html: 10) in /var/www/html/main.html on
line 11

Warning : Cannot send session cache limiter - headers already sent
(output (- etc etc like the one earlier))

(These are the lines containing session_start(); and
session_register("login"); in the main.html file)

In my phpinfo(), I find that
session.auto_start=ON
session.cookie_limiter i=nocache
session.cache_expire=180
session.save_path=/tmp
session.serialize_handler=php

Where could I be wrong ?

Raju



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Session variables

2001-03-13 Thread Mick Lloyd

I'm experimenting with sessions and note that you seem to able pass a query
result id via an include but not via an . Is this correct or
have I got it wrong? Do I need to do something to $session[result] before
passing it via ?  Example scripts:

session.phtml:
$connection = mysql_connect($DBHost,$DBUser,$DBPass);
mysql_select_db("$DB");
session_start();
session_register("session");
$session["result"]=mysql_query("select * from $TA");
$rows = mysql_num_rows($session[result]);
echo "Rows in session = $rows";
echo "Pass";
echo "Send";
include ("sessionresult.phtml");

sessionrows.phtml:
echo " Rows in sessionrows = $rows";

sessionresultid.phtml:
$rows = mysql_num_rows($resultid);
echo " Rows in sessionresultid = $rows";

sessionresult.phtml:
$rows = mysql_num_rows($session[result]);
echo "Rows in sessionresult = $rows";

Output from session.phtml reads:
Rows in session = 7
Pass
Send
Rows in sessionresult = 7

Clicking on Pass outputs "Rows in sessionrows = 7" as expected. But Clicking
on Send outputs the "Warning: Supplied argument is not a valid MySQL result
resource ..." error. I also get this when I click Back from either
sessionrows.phtml or sessionresultid.phtml. Again not sure why?

Any help gratefully received.

Mick Lloyd
[EMAIL PROTECTED]
Tel: +44 (0)1684 560224



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]