Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Oct 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    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.

  • #3
    New Coder
    Join Date
    Oct 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,791
    Thanks
    19
    Thanked 156 Times in 147 Posts
    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.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #5
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts
    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();



  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •