Page 1 of 1

calling a php counter from an index.html file

Posted: Tue May 27, 2003 8:52 pm
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

Posted: Tue May 27, 2003 9:50 pm
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 ;
)

Posted: Tue May 27, 2003 10:33 pm
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

Posted: Wed May 28, 2003 4:49 am
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!

Posted: Wed May 28, 2003 9:22 am
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.

Posted: Wed May 28, 2003 7:39 pm
by ISpyTy
avatar, lol, good point. I hate being to focused and over analyzing, gets really old after a while. thx, it works!!!

-Tyler

Posted: Wed May 28, 2003 8:48 pm
by AVATAr
There are many ways to reach to the same result :wink:

Posted: Sat May 31, 2003 5:34 pm
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;
?>