Forum Moderators: coopster
Look for "php addtype".
<!--#include virtual="myfile.php" -->
You can include any scripting processing in the php file. The server completes any server side scripting (database calls etc) in the php file before it is called into your .html file.
1. If you have available to you cpanel or the windows equivalent then you can simply turn on SSI, add .htm and .html to your list and begin to include SSI's within your html pages.
<!--#include virtual="myfile.php" -->
2. You can reference a small javascript
<script language="javaScript" src="myfile.php"></script>
Do note that the "type" has been left out on purpose.
Using the method you will also have to modify your echo statments as well. Sometimes they have a funny effect if you don't break them up. If you don't have any problems then don't fix it... if you start to have problems then look at your echo statements
3. This is just the opposite....
If you want to send information to a php file such as the title of the webpage
You can utilize the following method
<script language="JavaScript">
var image = "../pixel.gif";
var title = escape(document.title);
var link = "<img src='../myphpfile.php?title=" + title + "&img=" + image + "' align='middle' style='display:none' alt='©0'>";
document.write(link); //This will write out to the page
</script>
Now on your PHP page you include the following:
$title = $_GET['title']
That will transfer the information from JavaScripting via the URL to the PHP page and now you can do what you want with it via PHP.
Hope it helps
Wayne
[edited by: jatar_k at 3:48 pm (utc) on May 30, 2004]
[edit reason] no sigs thanks [/edit]
Your include statement is only working on shtml files because your .htaccess file (if you are allowed to use one) needs to be altered. Here is a sample .htaccess file command to allow includes for .htm .html and .shtml
AddType text/x-server-parsed-html .shtml .html .htm
Other unrelated uses for this .htaccess file may be as follows:
ErrorDocument 404 [mydomain.co.uk...]
this gives a smooth 404 redirect, also if your home page does not happen to be a default one, use this:
DirectoryIndex myfile.php
There are other commands you can add to the .htaccess file including modrewrite statements. Below is a compilation of the ones above which can be pasted into a text file, amended, and saved as .htaccess and tried:
AddType text/x-server-parsed-html .shtml .html .htm
ErrorDocument 404 [mydomain.co.uk...]
DirectoryIndex myfile.php