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 2 of 2

Thread: php_self

  1. #1
    Regular Coder
    Join Date
    Apr 2003
    Location
    Canada, Ontario, Mississauga
    Posts
    312
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php_self

    Hello,

    lets say I have a url www.testing.net/hello/testing.php

    when I use php_self as a link
    <a href="<?php echo"$PHP_SELF"; ?>">dont work</a>
    It will go to www.testing.net/hello/
    but it doesn't include the file name. what happen to testing.php when using $PHP_SELF?
    (I also tried $_SERVER[PHP_SELF], didn't work)

    When I use $PHP_SELF in a form
    <form action=<?php echo"$PHP_SELF"; ?> method=POST>
    with form, it will work perfect...

    Also,
    <a href="<?php echo "$PHP_SELF?test=69" ?>">works</a>
    it will works too..

    Can someone tell me why?

    Thank you all

    Mike

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Well the proper way would be:

    <a href="<?php echo $_SERVER["PHP_SELF"]; ?>">

    <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method=POST>
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster


  •  

    Posting Permissions

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