I'm trying to make a page view counter. I'm a newbie to PHP. Here is my problem: I'm using this code in "index.php":
<?php
include "visitcounter.php";
?>
And using the following code in "visitcounter.php":
<?php
session_start();
if(isset($_SESSION['visitcount']) {
$_SESSION['visitcount'] = $_SESSION['visitcount']+1;
} else {
$_SESSION['visitcount'] = 1;
}
echo "Total Page Views = ".$_SESSION['visitcount'];
?>
The problem is the page index.php is showing server error. If I change the code with the following code in index.php:
<?php
include "/visitcounter.php";
?>
Then the page not show any error message but display nothing. Anyone please help me to figure out what is the wrong I'm doing.