Development $php_self;

Discussion in 'Software' started by bradford010, 22 Aug 2002.

  1. bradford010

    bradford010 Bradon Frohman

    Joined:
    7 Dec 2001
    Posts:
    3,426
    Likes Received:
    0
    Should I be aware of any problems with this under Win2K?

    I had a HTML form calling a php script working sweet. Then I combined them using a call to $PHP_SELF; as the action and it just doesn't want to know.:(
     
  2. linear

    linear Minimodder

    Joined:
    5 Oct 2001
    Posts:
    4,393
    Likes Received:
    1
    This isn't a Win2k thing, it's a "new versions of PHP have more restrictive default autoglobal behavior" thing.

    I can see the need for a sticky on this topic, but for now, check out this thread: http://forums.bit-tech.net/showthread.php?s=&threadid=13937

    $_SERVER['PHP_SELF'] is the new equivalent superglobal.
     
  3. bradford010

    bradford010 Bradon Frohman

    Joined:
    7 Dec 2001
    Posts:
    3,426
    Likes Received:
    0
    Ah, right. Tried that before but looks like my syntax was a little off. Now if I can just get rid of the
    message. :/
     
  4. moose

    moose What's a Dremel?

    Joined:
    12 Mar 2001
    Posts:
    789
    Likes Received:
    1
    Either turn off error reporting for that page, or you (prolly) need to define Submit before doing things with it.

    If you dont mind, paste line 2 onto here and I'll take a gander :)
     
  5. bradford010

    bradford010 Bradon Frohman

    Joined:
    7 Dec 2001
    Posts:
    3,426
    Likes Received:
    0
    Yeah, it's pretty obvious I need to declare the variable, but of course $Submit is used on the next line for a comparison in an if statement.
    Which means when the script calls itself, the variable will be redefined, and the block of code that should execute, wont.

    Think I may tackle this by just implementing sessions now instead of in a few days.

    Unless someone has a better suggestion.

    btw, the reason it says 'undefined index' and not 'undefined variable' is because I'm using $_POST["Submit"] as opposed to $Submit. I've tried both, no joy.
     
  6. bradford010

    bradford010 Bradon Frohman

    Joined:
    7 Dec 2001
    Posts:
    3,426
    Likes Received:
    0
    Or I could use isset(). :rolleyes:

    <condescendingTone>Pfft, really Bradford</condescendingTone>
     
  7. moose

    moose What's a Dremel?

    Joined:
    12 Mar 2001
    Posts:
    789
    Likes Received:
    1
    heh :)

    If you find you still get errors a little like the one you had, even when you're using isset() - try using empty() insted, which is my preference since I had a lot of errors like yours when using full error reporting.
     
  8. bradford010

    bradford010 Bradon Frohman

    Joined:
    7 Dec 2001
    Posts:
    3,426
    Likes Received:
    0
    cheers, that one goes in php notebook:D

    /me starts a php notebook. :hehe: :hehe: :hehe:
     

Share This Page