calling a php counter from an index.html file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ISpyTy
Forum Newbie
Posts: 9
Joined: Wed Mar 19, 2003 11:42 pm

calling a php counter from an index.html file

Post by ISpyTy »

calling a php counter from an index.html file? any ideas?

as soon as someone arrives at index.html, it calls a php file to record the page name and then increments the counter +1, no else sees the counter, just me. it's kept in it's own little txt file with the filename (in this case index.html) as the title. can anyone help me with just the calling the script from a html file?

thx,
Tyler
User avatar
Zoram
Forum Contributor
Posts: 166
Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:

Post by Zoram »

Unless php is parsing your html files ( i think they can do that ) then you would have to have something from the hmtl that calls a php file to load... but that would be kinda like a redirect... so either make it a index.php and put a script at the top that increments or redirect it through other pages... that's how i think it works... I could be disatrously wrong though ;
)
ISpyTy
Forum Newbie
Posts: 9
Joined: Wed Mar 19, 2003 11:42 pm

Post by ISpyTy »

But can you do that? have the default index be a php file? i thought it HAD to be index.htm(l). So i could just have say index.php and it would make that the default page? i didn't know that...if im correct in my guessing then i learned a new trick, cool. anyway, this is how i understand what u said:
1. make an index.php that does the counter, then redirects to index.htm

i guess i could put the source code into the php file, but while complicate things?

thx a gigabyte,

Tyler
User avatar
werlop
Forum Commoner
Posts: 68
Joined: Sat Mar 22, 2003 2:50 am
Location: /dev/null

Post by werlop »

It all depends how the webserver is setup, you could actually have anything, you could set the webserver's default page to asfagagbagsafd.gadlkj if you really felt like it!

In apache this is configured by editing the DirectoryIndex setting, this is what mine looks like:

Code: Select all

DirectoryIndex index.html index.html.var index.php
I think the items listed first have more priority, although I could be wrong!
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

ISpyTy wrote: make an index.php that does the counter, then redirects to index.htm
You don't have to redirect to index.htm, only change the extension of the index.html to index.php. And then insert the code of the counter in the top of it.
ISpyTy
Forum Newbie
Posts: 9
Joined: Wed Mar 19, 2003 11:42 pm

Post by ISpyTy »

avatar, lol, good point. I hate being to focused and over analyzing, gets really old after a while. thx, it works!!!

-Tyler
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

There are many ways to reach to the same result :wink:
User avatar
nickvh
Forum Newbie
Posts: 11
Joined: Sat May 31, 2003 3:37 pm
Location: VA, USA
Contact:

Post by nickvh »

<img src="counter.php?page=index.html"> in index.html then:

Code: Select all

<?
//insert counter processing code here

//return an image
$fp=@fopen("img/ok.jpg","rb");
$file_cont=fread($fp,filesize("ok.jpg"));
@fclose($fp);
echo $file_cont;
?>
Post Reply