Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-21-2006, 02:46 PM   PM User | #1
raymanw
New Coder

 
Join Date: Oct 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
raymanw is an unknown quantity at this point
Help with syntax

Hi,

Please help me verify the syntax of the following:

<form name=formlogin action="<?php echo $_SERVER['PHP_SELF']; ?>?homeinclude=memberupdate&pageaction=signup" method=post>

I am getting a strange problem of unable to bring down the value of $_SESSION variable to the 3rd page & I suspect that it has something to do with syntax.

Thanks

Last edited by raymanw; 11-21-2006 at 03:03 PM..
raymanw is offline   Reply With Quote
Old 11-21-2006, 09:22 PM   PM User | #2
marek_mar
Sensei


 
Join Date: Aug 2003
Location: One step ahead of you.
Posts: 2,815
Thanks: 0
Thanked 3 Times in 3 Posts
marek_mar is on a distinguished road
The syntax is correct.
To use sessions/ the $_SESSION array you have to initialize the session with session_start() on every page. POST and/or GET data won't go into the $_SESSION array automatically, you have to add them yourself.
__________________
I'm not sure if this was any help, but I hope it didn't make you stupider.

Experience is something you get just after you really need it.
PHP Installation Guide Feedback welcome.
marek_mar is offline   Reply With Quote
Old 11-22-2006, 12:34 PM   PM User | #3
raymanw
New Coder

 
Join Date: Oct 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
raymanw is an unknown quantity at this point
Thanks for the tip.

Is it feasible to include session_start() multiple times in 1 page?

I am using the same page, sometimes alone & sometimes as an included in other pages. As an include I need to specify it at the top of the calling page.

For example:
I am using $_SESSION in page1.php.
I want to include page1.php in page2.php.
But sometimes I want to run page1.php by itself.

Is it ok to specify it in both the pages?

Thanks.
raymanw is offline   Reply With Quote
Old 11-22-2006, 12:50 PM   PM User | #4
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
Quote:
Is it feasible to include session_start() multiple times in 1 page?
Usually, I;d say "no"...but in this case, I'd say it's OK (I don;t think the PHP police will be knocking on your door if you catch my drift)...

The first time on your parent page, use

PHP Code:
session_start(); 
Then on included pages, or pages that may or may not be included in the parent page, use

PHP Code:
@session_start(); 
to suppress the "headers already sent" warning messages I think you will probably get...but the code should still function....well I think it should, but I haven;t tested this theory
__________________
Regards, R.J.
chump2877 is offline   Reply With Quote
Old 11-22-2006, 01:03 PM   PM User | #5
SeeIT Solutions
Regular Coder

 
Join Date: May 2005
Posts: 563
Thanks: 0
Thanked 3 Times in 3 Posts
SeeIT Solutions is on a distinguished road
I would put session_start(); at the top of page2.php and at the top of page1.php use:

PHP Code:
if (empty(session_id())) {
session_start();

__________________
Design Portfolio
SeeIT Solutions is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 09:52 AM.


Advertisement
Log in to turn off these ads.