PHP include function doesn't work in HTML file
Posted: Sun Apr 11, 2010 2:40 pm
I am trying to implement a contact form, and the instructions to do so are found here: http://westworldvideos.com/contact/help/
I cannot get past the first step: "Include the 'contact-script.php' file in the page area where you want to see the contact form."
It tells me to use the following code:
But I'm not sure if this is right. What is that "/path/to/public_html/" part?
The way my site works is like this:
index.php file opens a layout.html file, where there's an include to include the content depending on "index.php?go=contact", for example, and the contact.html resides in root/html/contact.html, and it's just the sheer content. Perhaps this is causing the problem?
This is index.php for your interest:
As you noticed, the contact.html I'm trying to implement the php code in isn't a .php file, but I have added the following into htaccess, and it works to put php in other html files:
What do you think the problem is?
I hope to hear from you![/php]
As you noticed, the contact.html I'm trying to implement the php code in isn't a .php file, but I have added the following into htaccess, and it works to put php in other html files:
[text]RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html[/text]
What do you think the problem is? To outline it again, the problem is that this code isn't working - there's nothing in the browser.
I hope to hear from you!
P.S. I changed the code to:
<?php include("contact-script.php"); ?>
And now it appears in the source code in the browser!
I cannot get past the first step: "Include the 'contact-script.php' file in the page area where you want to see the contact form."
It tells me to use the following code:
Code: Select all
<?php
include '/path/to/public_html/yourwebsite.com/contact-script.php';
?>
The way my site works is like this:
index.php file opens a layout.html file, where there's an include to include the content depending on "index.php?go=contact", for example, and the contact.html resides in root/html/contact.html, and it's just the sheer content. Perhaps this is causing the problem?
This is index.php for your interest:
Code: Select all
<?php
$go = "index" ;
if ($_GET["go"])
$go = $_GET["go"] ;
$body = "html/{$go}.html" ;
$head = "html/_{$go}.html" ;
if (!file_exists($body)) {
$body = "html/index.html" ;
}
if (!file_exists($head)) {
$head = "html/_index.html" ;
}
$CONTENT = implode('', file($body)) ;
$HEAD = implode('', file($head)) ;
include "layout.html" ;
?>Code: Select all
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .htmlI hope to hear from you![/php]
As you noticed, the contact.html I'm trying to implement the php code in isn't a .php file, but I have added the following into htaccess, and it works to put php in other html files:
[text]RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html[/text]
What do you think the problem is? To outline it again, the problem is that this code isn't working - there's nothing in the browser.
I hope to hear from you!
P.S. I changed the code to:
<?php include("contact-script.php"); ?>
And now it appears in the source code in the browser!