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 4 of 4
  1. #1
    Regular Coder
    Join Date
    May 2009
    Posts
    813
    Thanks
    123
    Thanked 24 Times in 24 Posts

    Include a php page

    I want to include a php page, lets say for the members.html webpage. This is to password protect just one webpage.

    Would I have to change the members.html webpage to members.php if I were to add the following code?
    Or can I mix them both.

    Code:
    <?php include("/home/haveahobby/htdocs/protector/password_protect.php"); ?>
    complete newbie in php

  • #2
    Regular Coder
    Join Date
    Dec 2007
    Posts
    137
    Thanks
    1
    Thanked 21 Times in 21 Posts
    Yes you would have to change it. Files with the .html, .htm file extensions aren't parsed by PHP, therefore that PHP code in your members.html would not get executed. Only if you change it to "members.php".

  • #3
    Regular Coder
    Join Date
    May 2009
    Posts
    813
    Thanks
    123
    Thanked 24 Times in 24 Posts
    thanks I had a feeling I would, saved me lots of time

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    It should be mentioned that this is not necessarily the case. The web server itself determines what it considers to be PHP parsable code, and can have its directives redefined to reflect this. .html, .php, .pl, and so forth mean nothing; they are merely conveniences that have been created (especially try in a *nix system). You can technically change a .txt file to be parsed as PHP if you really wanted.

    This said, stick to .php, this ensures the greatest portability since we no longer use shebang lines in our PHP processing (though if you run as a cgi you could probably just use shebang line without regard to the extension at all).
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

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