PHP SELF problem

Discussion in 'PHP' started by Zolka, Feb 12, 2010.

  1. #1
    Helo!
    When I add the code:<form action="<?php echo $PHP_SELF;?>" method="post" > to a html script, I get the error message "You don't have permission to access /< on this server." I tried to modify the action code using print instead of echo and $_SERVER['PHP_SELF'] instead of $PHP_SELF, but still doesn't work. I use WAMP by the way!Do I have to modify the php.ini, maybe!?
    Please help!:confused:
     
    Zolka, Feb 12, 2010 IP
  2. 0x00

    0x00 Well-Known Member

    Messages:
    122
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    115
    #2
    Check the source code of the HTML when you open the PHP file from your browser, what does it show in the form action?

    stupid question but, are you sure you are saving the file as .php? seems like the PHP is not getting rendered at all..
     
    0x00, Feb 12, 2010 IP
  3. bugcoder

    bugcoder Peon

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I strogly condemn this word "stupid"...if someone is new to any field he not stupid he is just inexperienced.
     
    bugcoder, Feb 12, 2010 IP
  4. 0x00

    0x00 Well-Known Member

    Messages:
    122
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    115
    #4
    I did not call him stupid, I called my question stupid. learn2english
     
    0x00, Feb 12, 2010 IP
  5. bugcoder

    bugcoder Peon

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    fight ends here. it can be taken both ways:p
     
    bugcoder, Feb 12, 2010 IP
  6. HuggyStudios

    HuggyStudios Well-Known Member

    Messages:
    724
    Likes Received:
    20
    Best Answers:
    26
    Trophy Points:
    165
    #6
    I think he was trying to check if a obvious mistake had been made, not trying to insult the guy.
     
    HuggyStudios, Feb 12, 2010 IP
  7. HivelocityDD

    HivelocityDD Peon

    Messages:
    179
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Looks like your file type is .html, it should be .php

    and try echo $_SERVER['PHP_SELF'] instead of $PHP_SELF

    Hope it will help.

    You can write html on php file but you cant do the opposite to make it work properly

    Thanks
     
    HivelocityDD, Feb 12, 2010 IP
  8. Zolka

    Zolka Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Helo!
    Here is my HTML code:

    <html>
    <?php
    if (!empty($_POST['tipp']))
    {
    print "Az utolso tipp: ".$_POST['tipp']"";
    }
    ?>
    <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" >
    <input type="submit" value="rendben">
    <p>
    Ide irja tippjet:<input type="text" name="tipp"/>
    </p>
    </form>
    </html>

    I saved it as 2.html, when I type it to the browser a textfield appears, then I write some text there, and when I press Rendben(Submit), the error message appears.
    I think this should clarify what the problem is!
    I will try to make changes according to your suggestions.
    Thanx

    p.s. (I started learning php 2 weeks ago)
     
    Zolka, Feb 12, 2010 IP
  9. Zolka

    Zolka Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    You were right, I saved it as HTML instead of PHP.
    Thanx for your help
     
    Zolka, Feb 12, 2010 IP