Forum Moderators: open

Message Too Old, No Replies

Include PHP file in HTML file

         

jshpik1

2:17 pm on Jun 20, 2005 (gmt 0)

10+ Year Member



Hello,

I'm trying to include a PHP (header & footer) file in an HTML file.

The reason it needs to be HTML is this is a content provider that hosts the content and they've put a restriction on the number of characters that can be in the header (as they host it). Any ideas?

I've tried <!--# include FILE="http://www.example.com/templates/header.php" -->

Thanks.



[edited by: not2easy at 1:57 pm (utc) on Jan 19, 2023]
[edit reason] privacy/user request [/edit]

BetterSEO

2:43 pm on Jun 20, 2005 (gmt 0)

10+ Year Member



If you're using <filename>.html, your server needs to know that it should parse the data before it serves the page to the user. It depends on the server, but you can usually change the extension to <filename>.shtml or you can use an .htaccess file to instruct the server to parse .html files.

jshpik1

6:08 pm on Jun 20, 2005 (gmt 0)

10+ Year Member



But I'm calling on the PHP from an HTML source. Because the code is not hosted by me I can't change file names or anything. Any other suggestions?

jatar_k

6:10 pm on Jun 20, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld jshpik1,

I am a little confused

that is an SSI include style, so you want include a php file via SSI or were you just looking to enable php in your html files and use a php include?

Farix

12:34 pm on Jun 21, 2005 (gmt 0)

10+ Year Member



The only way to include another file into an HTML file is by old fastion C&P. Otherwise, you have to use SSI (with the file extension of .shtml) or PHP (with the file extension of .php).

jshpik1

2:22 pm on Jun 21, 2005 (gmt 0)

10+ Year Member



Hello,

I'm thinking it's not possible then, here's the issue...

I doing this through a content provider which hosts the header and footer code, so it blends in with your site. They'll only allow a certain number of characters in the header and footer, I exceed that number by quite a bit.

Another restriction is that it can only be HTML, because that's what they're program saves it as. Thanks.

By the way, what's C&P?

Jason Shphik

Farix

2:24 pm on Jun 21, 2005 (gmt 0)

10+ Year Member



Copy and Paste

BTW, if you have those kinds of restrictions, I advice you go look for another hoster.

Betjeman

2:35 pm on Jun 21, 2005 (gmt 0)

10+ Year Member



You could use Javascript to dynamically populate header and footer divs, and host that script in an external file.

Eg:

FILE: test.html


<html>
<head>
<script language="javascript" src="test.js"></script>
</head>
<body onload="loadHeader()">
<div id="header"></div>
<div id="content">This is the content.</div>
<div id="footer"></div>
</body>
</html>

FILE: test.js


function loadHeader()
{
document.getElementById("header").innerHTML = "header";
document.getElementById("footer").innerHTML = "footer";
}

jshpik1

4:12 pm on Jun 21, 2005 (gmt 0)

10+ Year Member



Of course, javascript, I hadn't even thought of that option. One more question though, where do I define what the header and footer code will be? Is that in the javascript file? If so where do I put it? Thanks.

Jason Shpik