View Full Version : Include a php page

11-25-2010, 11:53 PM
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.

<?php include("/home/haveahobby/htdocs/protector/password_protect.php"); ?>

complete newbie in php

11-26-2010, 12:16 AM
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".

11-26-2010, 01:06 AM
thanks I had a feeling I would, saved me lots of time

11-26-2010, 01:17 AM
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).