Connecting Tech Pros Worldwide Help | Site Map

Include php from html

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 12:54 PM
Luke Bellamy
Guest
 
Posts: n/a
Default Include php from html

Hi - I have been asked to add a hit counter to a standard HTML page.
I have found a php script to implement the counter but need to show it
on the html page.
I cannot include a PHP in the html file can I? the web server will not
pre-parse a html file correct?

I would like to put the PHP hit counter on the web site that only
contains html files. Anyone have a good idea how I can do this without
chaning all the files to .php?

Thanks,
Luke Bellamy
Newcastle, Australia

  #2  
Old July 17th, 2005, 12:54 PM
Tony Marston
Guest
 
Posts: n/a
Default Re: Include php from html

It is most definitely possible to include a PHP counter in an HTML file
because I have been doing it for years. In my HTML file I include a link as
follows:

<p><img src="http://www.mydomain.com/counter.php?page=/whatever.html"
alt="counter" border="0"></p>

The PHP script 'counter.php' uses the 'page=' argument to identify which
document to count, then outputs the result as an image.

Easy peasy lemon squeezy.

--
Tony Marston

http://www.tonymarston.net



"Luke Bellamy" <bellamy_luke@hotmail.com> wrote in message
news:3cab9daf.0504281916.68454042@posting.google.c om...[color=blue]
> Hi - I have been asked to add a hit counter to a standard HTML page.
> I have found a php script to implement the counter but need to show it
> on the html page.
> I cannot include a PHP in the html file can I? the web server will not
> pre-parse a html file correct?
>
> I would like to put the PHP hit counter on the web site that only
> contains html files. Anyone have a good idea how I can do this without
> chaning all the files to .php?
>
> Thanks,
> Luke Bellamy
> Newcastle, Australia[/color]


  #3  
Old July 17th, 2005, 12:54 PM
Alvaro G Vicario
Guest
 
Posts: n/a
Default Re: Include php from html

*** Luke Bellamy wrote/escribió (28 Apr 2005 20:16:29 -0700):[color=blue]
> I would like to put the PHP hit counter on the web site that only
> contains html files. Anyone have a good idea how I can do this without
> chaning all the files to .php?[/color]

You can instruct the webserver to pass *.html files through PHP
interpreter. If you are using Apache you may be able to use an .htaccess
file (unless prohibited by sysadmin):

# For Apache 2:
<Files *.html>
SetOutputFilter PHP
SetInputFilter PHP
</Files>


--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
  #4  
Old July 17th, 2005, 12:55 PM
cowofchaos@gmail.com
Guest
 
Posts: n/a
Default Re: Include php from html

You could also display the counter in a frame or <iframe> on the page,
I've done it before, sorry I can't give you an example right now, I
havn't used frames in ages

  #5  
Old July 17th, 2005, 12:56 PM
Mladen Gogala
Guest
 
Posts: n/a
Default Re: Include php from html

On Thu, 28 Apr 2005 20:16:29 -0700, Luke Bellamy wrote:
[color=blue]
> I cannot include a PHP in the html file can I? the web server will not
> pre-parse a html file correct?[/color]

Of course you can. That is what <?php....?> is for. Rough template looks
like this:

<html>
<head>
<title>
<?php Requires, class declarations and alike?> </head>
<body>
<tag>
<?php action ?>
</body>
</html>


It is one of the biggest advantages of PHP that is freely mixable with
HTML. Otherwise, you could use perl instead.

--
Egoist: A person of low taste, more interested in themselves than in me.

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.