SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member zed's Avatar
    Join Date
    Apr 2003
    Location
    SoCal
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Undefined variable: PHP_SELF

    I have just set up a new computer. This time with Apache 2 replacing IIS. I moved all the .php and .inc files from wwwroot to htdocs.

    Now when presenting a form I get the Undefined variable: PHP_SELF error. It allows the rest of the page to load just fine but the text box values seem to get lost.

    Is this a .cfg or .ini issue?

    TIA, Zed

  2. #2
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is most likely a register_globals issue.

    You'll need to replace $PHP_SELF with $_SERVER['PHP_SELF'] in your PHP files.

    or go
    PHP Code:
    $PHP_SELF $_SERVER['PHP_SELF']; 
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  3. #3
    SitePoint Member zed's Avatar
    Join Date
    Apr 2003
    Location
    SoCal
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sure enough, register_globals was set to Off. Once set to on the .php files work just as before.

    Thanks cyborg.


    OOOOOOOOOOO <= Some donuts for ya.

  4. #4
    jigga jigga what? slider's Avatar
    Join Date
    Oct 2002
    Location
    Utah (USA)
    Posts
    309
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    BTW, register globals was set to off by default for a reason. Might want to look into that a little bit before you go too far coding with it turned back on.

    [edit] Err... I just realized you already did some coding with it on then did a new Apache/PHP installation and it was off by default, so you've switched it back to on. Still the same suggestion, though. I'd look at what's needed to get your code compatible with it off.
    $slider = 'n00b';

  5. #5
    SitePoint Member zed's Avatar
    Join Date
    Apr 2003
    Location
    SoCal
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Based on the disclaimer related to globals I am open to an alternative. I am a purist when it comes to doing things correctly.

    Being a novice with PHP I do not see the harm storing values in a space not visible to the client. I have many constants loaded to the global array based on values in the db when the user logs in. I find this to be more manageable than looking up values in a text file.

    As far as the forms go, PHP_SELF, I can keep these values from view using the globals vs. arguements visible in the http address.

    Please post any links for tutorials and conversation threads along these thought lines.

    Thanks for the interest and taking time to post the warning, zed

  6. #6
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by zed
    Please post any links for tutorials and conversation threads along these thought lines.
    Kevin Yank covers this issue in this article: Write Secure Scripts with PHP 4.2.
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  7. #7
    SitePoint Member zed's Avatar
    Join Date
    Apr 2003
    Location
    SoCal
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This community is great!

    I will embark on the new and secure way to use globals tomorrow.

    Thanks again, zed


Bookmarks

Posting Permissions

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