View Full Version : Help with syntax

11-21-2006, 02:46 PM

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.


11-21-2006, 09:22 PM
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.

11-22-2006, 12:34 PM
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?


11-22-2006, 12:50 PM
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


Then on included pages, or pages that may or may not be included in the parent page, use


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 :rolleyes:

SeeIT Solutions
11-22-2006, 01:03 PM
I would put session_start(); at the top of page2.php and at the top of page1.php use:

if (empty(session_id())) {