Jump to content

php in a html file


tommy20

Recommended Posts

I am trying to use a php hit counter by calling it through  a html file using the following. <? include "counter.php"; ?> But nothing happens



The php file is and is set to 777

<?php
?>

<?php
$count_my_page = ("hitcounter.txt");
?>

<?php
$count_my_page = ("hitcounter.txt");
$hits = file($count_my_page);
?>

<?php
$count_my_page = ("hitcounter.txt");
$hits = file($count_my_page);
$hits[0] ++;
?>

<?php
$count_my_page = ("hitcounter.txt");
$hits = file($count_my_page);
$hits[0] ++;
$fp = fopen($count_my_page , "w");
?>

<?php
$count_my_page = ("hitcounter.txt");
$hits = file($count_my_page);
$hits[0] ++;
$fp = fopen($count_my_page , "w");
fputs($fp , "$hits[0]");
?>

<?php
$count_my_page = ("hitcounter.txt");
$hits = file($count_my_page);
$hits[0] ++;
$fp = fopen($count_my_page , "w");
fputs($fp , "$hits[0]");
fclose($fp);
?>

<?php
$count_my_page = ("hitcounter.txt");
$hits = file($count_my_page);
$hits[0] ++;
$fp = fopen($count_my_page , "w");
fputs($fp , "$hits[0]");
fclose($fp);
echo $hits[0];
?>



What am I doing wrong
Link to comment
https://forums.phpfreaks.com/topic/28663-php-in-a-html-file/
Share on other sites

You CAN tell your server to process HTML files through the PHP engine.  Other than doing so, you're going to have to either forget this plan or change the extension(s) of your file(s) to php.

Are you using CPanel?  As that's one of the most common features of web hosting plans out there, I'm going to guess 'yes'.

In CPanel, click on [b]Apache Handlers[/b].  Then in [b]Extention(s)[/b] type [b]HTML[/b].  In [b]Handler[/b] field, enter [b]application/x-httpd-php[/b].
Link to comment
https://forums.phpfreaks.com/topic/28663-php-in-a-html-file/#findComment-131263
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.