SitePoint Sponsor

User Tag List

Results 1 to 15 of 15
  1. #1
    SitePoint Enthusiast Adam Black's Avatar
    Join Date
    Oct 2000
    Location
    Nova Scotia, Canada
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    <?=$PHP_SELF?> loads same script right?

    if you put this in a link or a from action it is supposed to load the same page right?
    <?=$PHP_SELF?>

    because i put that as a form action and then when i click submit it has http://www.nethorde.com/users/adamblack/<?=$PHP_SELF?> in the address bar and it displayes my hosts custom error message.

  2. #2
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    are you using post or get as the form action?
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  3. #3
    SitePoint Enthusiast Adam Black's Avatar
    Join Date
    Oct 2000
    Location
    Nova Scotia, Canada
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    post why does it matter?

  4. #4
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it depends on what the form is doing either retrieving or inserting to a db.

    but you can leave the form action blank, and it will automatically reload the page, i.e. no need for the php_self.
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  5. #5
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: <?=$PHP_SELF?> loads same script right?

    Originally posted by Adam Black
    because i put that as a form action and then when i click submit it has http://www.nethorde.com/users/adamblack/<?=$PHP_SELF?> in the address bar and it displayes my hosts custom error message.
    $PHP_SELF (actually you should use $HTTP_SERVER_VARS['PHP_SELF'] in PHP 4) is the REQUEST_URI. that is, it's everything after the domain, NOT just the filename of your script. so in your example it should be http://www.nethorde.com<?=$PHP_SELF?>


    EDIT > maybe i misread your question. i don't know. sorry if i did.
    Last edited by DR_LaRRY_PEpPeR; Sep 22, 2001 at 14:48.
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  6. #6
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and are you sure the code is correct in your file?

    i.e. correct placement of " or ' and inclusion of $ etc.

    Maybe post the exact code you are using...
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  7. #7
    HI silver trophy Silverado4x4's Avatar
    Join Date
    Jan 2001
    Location
    USA
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:

    PHP Code:
    <? $PHP_SELF ?>

  8. #8
    SitePoint Wizard Aes's Avatar
    Join Date
    Jun 2001
    Location
    Oklahoma
    Posts
    3,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's
    PHP Code:
    <? echo($PHP_SELF); ?>
    or
    PHP Code:
    <?=$PHP_SELF;?>
    Why would you put it in the URL (i.e. http://www.nethorde.com/users/adamblack/file.php<? $PHP_SELF; ?>)? Just put it in the action=" " attribute and it will take care of itself.

    Wait. That wouldn't even work. It would have to be something like http://www.nethorde.com/users/adamblack/file.php?$php_self=1, right? Since $PHP_SELF probably evaluates to either true or false (i.e. 1 or 0 respectively). If I'm wrong there, I apologize. However, <? $PHP_SELF; ?> would not be a part of the URL.
    Colin Anderson
    Ambition is a poor excuse for those without
    sense enough to be lazy.

  9. #9
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just print out the $PHP_SELF variable...it'll spit out the location to the current script. If you're using it in a <form> tag, then there won't be any problem...you don't need to specify anything else...just the variable.

  10. #10
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    because i put that as a form action and then when i click submit it has http://www.nethorde.com/users/adamblack/<?=$PHP_SELF?> in the address bar and it displayes my hosts custom error message.
    If he is clicking the submit button and <?=$PHP_SELF?> ends up in the address bar, then the php wasn't parsed on the page where you had <?=$PHP_SELF?> because if it had been parsed that wopuld not have appeared in the address bar.

    So are you sure your host has support for php and if so are you using the correct file extension. Normally .php or .php3. So start with that. An easy way to test this is to view the html cource of the form page using view source in the right click menu of IE. If you see <?=$PHP_SELF?> in there then php is not working properly on your server.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  11. #11
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <form action="<?=$PHP_SELF?>" method="POST">
    always works fine for me.
    Like freddy said, check that php's installed and your file extensions are correct.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  12. #12
    Probably eating pie mitsubishi's Avatar
    Join Date
    Sep 2001
    Location
    England, UK
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Surely if its's not parsing it means that short handles are not allowed and <?php echo $PHP_SELF?> should be be used, rather than just <?

  13. #13
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think the form i posted above is only available in php version 4 and greater
    so you'll have to do
    PHP Code:
    <? echo $PHP_SELF?>
    if you want to use it in the action part of the form tag.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  14. #14
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by weirdbeardmt
    but you can leave the form action blank, and it will automatically reload the page, i.e. no need for the php_self.
    This may be true for IE but I'm not sure that it is true for all browsers?

  15. #15
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know for a fact that NS4.* needs to have a valid action in the <form> tag or it will give you a 404 error. The omission of the action attribute will only work in IE like freakysid said.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •