Forum Moderators: coopster

Message Too Old, No Replies

HTML Pages

running a php script from an html page

         

NancyJ

10:08 pm on Dec 11, 2004 (gmt 0)

10+ Year Member



Is there any way to run a php script from an HTML file.
I'm writing a webstats thing for my website, which is fine for me cos my whole site in wrapped in a crispy php shell but what if I wanted to share it with other people and they were using html pages, could they use it without having to change all their file extentions to .php?

Storyman

11:46 pm on Dec 11, 2004 (gmt 0)

10+ Year Member



Nancy,

You could set up your site so PHP is run as HTML. That way the regular HTML pages will work while the PHP pages will appear with the extension of HTML instead of PHP.

The way to accomplish this depends on if you have access to the PHP config file. If you do have access, then you make the change in the config file. If you don't, then it needs to be done in .htaccess.

As with PHP there is more than one way to approach the problem. The solution I use is to insert the following line in the .htaccess file:

AddType application/x-httpd-php .php .html

NancyJ

12:17 am on Dec 12, 2004 (gmt 0)

10+ Year Member



I was kinda hoping for something a little more 'frontpage monkey' friendly. just chaing the file extension to .php is much easier for most than changing the .htaccess file :)

baze22

12:45 am on Dec 12, 2004 (gmt 0)

10+ Year Member



You could set it up like counter programs, so that they include it as in an img tag like:

<img src="myscript.php"> and have your script do it's thing and return a 1 pixel spacer.gif image.

baze

NancyJ

2:20 am on Dec 12, 2004 (gmt 0)

10+ Year Member



Ingenious! I would have never thought of that! Thanks!