SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jan 2003
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A question about the use of $PHP_SELF

    Hi:

    I'm studyng PHP programming.
    I tried the following example i got from a tutorial:

    <FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD=POST>
    <P>Type your joke hereBR>
    <TEXTAREA NAME="joketext" ROWS=10 COLS=40 WRAP></TEXTAREA><BR>
    <INPUT TYPE=SUBMIT NAME="submitjoke" VALUE="SUBMIT">
    </FORM>

    When I type a text into the form and submit it, I receive the message that it is unable to find the page

    with the URL:

    http://localhost/<br%20/><b>Notice</b>:%20%20Undefined%20variable:%20%20Server%20in%20<b>c:/inetpub/wwwroot/Basedat_1h.php</b>%20on%20line%20<b>29</b><br%20/>


    I'm using PHP version 4.3.0
    and PHPCoder

    Could you help me to find what is wrong please ?

    Jose Dean
    Matanzas.
    Cuba
    jolly-roger-pro@enet.cu

  2. #2
    SitePoint Member panda's Avatar
    Join Date
    Mar 2003
    Location
    Melbourne, Australia
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You'll need to use $_SERVER['PHP_SELF'] instead (or turn on the "register globals" directive in php.ini).

    Older versions of PHP (< 4.2.0) had register globals on by default, but since 4.2.0 have register globals is off.

    The example you quoted was no doubt based on one of the older PHP versions.

    For more information, try:

    http://www.php.net/manual/en/languag...predefined.php

  3. #3
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Self is the default action for a form so just leave it out.

  4. #4
    public static void brain Gybbyl's Avatar
    Join Date
    Jun 2002
    Location
    Montana, USA
    Posts
    647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Instead of using <?php echo($PHP_SELF); ?>, you can just use <?=$PHP_SELF?> as a shortcut.
    Ryan

  5. #5
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Gybbyl
    Instead of using <?php echo($PHP_SELF); ?>, you can just use <?=$PHP_SELF?> as a shortcut.
    that variable won't work with 4.3.0. Like has been mentioned - $_SERVER['PHP_SELF']

    But on top of that, despite the fact that he's not likely to be using XML namespaces anytime soon, using the short PHP tags like you suggest is not recommended do to conflict with XML.



    Aaron
    Aaron Brazell
    Technosailor



  6. #6
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Plus they may be disabled in the php.ini

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature


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
  •