473,699 Members | 2,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Jul 17 '05 #1
4 2116
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.co m/counter.php?pag e=/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" <be**********@h otmail.com> wrote in message
news:3c******** *************** ***@posting.goo gle.com...
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

Jul 17 '05 #2
*** Luke Bellamy wrote/escribió (28 Apr 2005 20:16:29 -0700):
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?


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
--
Jul 17 '05 #3
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

Jul 17 '05 #4
On Thu, 28 Apr 2005 20:16:29 -0700, Luke Bellamy wrote:
I cannot include a PHP in the html file can I? the web server will not
pre-parse a html file correct?


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.

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
15013
by: mark | last post by:
IF I have something like this: <title><?php print($pagetitle); ?></title> <body> <?php include("folders/my_include.php"); ?> </body> </html> and my_include.php contains the value to the variable ($pagetitle). How do I get the value before the code for the <title> is written. This is just a
2
2140
by: Greg | last post by:
I'm new to html and web coding, this is a simple one - appreciate your help! I'm attempting to get my browser bar links to reside in a single .asp file to avoid multiple additions to pages when I add a page to the site. I've done a lot of reading and surfing, believe I know how to do it, but can't get it to work. I've installed IIS on my machine running XP pro, and have
14
1667
by: Adam | last post by:
Hi All, Is it possible to use includes dynamically in html. Hopefully the following example will give an idea what I am rying to do. Thanks in advance Adam <script language="javascript">
6
2120
by: tshad | last post by:
In my User control, I tried to do this: *************************************************************************** <Script runat="server"> Public ClientName As String = "<!-- #include file = ...\includes\StaffingHeaders.inc -->" </Script> <%=ClientName%> ****************************************************************************
11
2263
by: MBS | last post by:
I am playing around with some PHP code. I want to put in an include() function so I can include existing HTML code and output it to the browser. Lo and behold PHP does not support relative paths with the include() function! (How shortsighted can you get?) Is there any way at all to use relative paths with include()? Any hacks? If I use an absolute filepath, everything is fine. But I don't want to do that--I can't do that. I want...
2
5356
by: Asterbing | last post by:
Hi all. I'm trying and don't succeed to include an HTML page into another without any border nor visible scroll-bar. Even if I would like something which will work under Netscape too, at this point, my tests are made under IE6 with the following HTML files, using <object>, <embed> and <iframe> : The main HTML page : ******************** <html> <head>
11
26608
by: cybervigilante | last post by:
I can't seem to change the include path on my local winmachine no matter what I do. It comes up as includ_path .;C:\php5\pear in phpinfo() but there is no such file. I installed the WAMP package and PEAR is in c:\wamp\php\pear I modified php.ini in the c:\wamp\php directory to reflect the actual path, but even stopping and restarting my server shows the c: \php5\pear path. I can't change it no matter what I do I also tried the...
4
3377
by: Jon Slaughter | last post by:
I'm using eval to excute some mixed php and html code but I cannot debug it. I am essentially using filegetcontents to load up a php/html file and then inserting it into another php/html file and then using eval to execute the final product. If I were to use include and output buffering instead of filegetcontents would it allow be to debug the code? (I have to capture the include so it can be modified which is why I used...
14
3147
by: Michael | last post by:
Since the include function is called from within a PHP script, why does the included file have to identify itself as a PHP again by enclosing its code in <?php... <?> One would assume that the PHP interpreter works like any other, that is, it first expands all the include files, and then parses the resulting text. Can anyone help with an explanation? Thanks, M. McDonnell
6
4185
by: j.woodcock | last post by:
is there a way of having a file that's name is a variable (eg dependant on the user name) act like a include. i know that you cant define the file for an include asp tag using a variable and that reading the file using "Response.Write FSO.OpenTextFile(ppp, 1, False, False).readall" prints the file, and treating it like a html file. can anyone suggest another way of doing this?
0
8687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8615
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9034
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8914
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8883
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7750
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6534
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4376
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.