Simple Counter & Redirecting & Browser Type

Simple Counter

This is a really 2 file way of making a unique hit counter.

If you make a new file called counter.txt and just type the number 1 on the first line.

In a new file, paste the script

<?
$file = "counter.txt";
$fp= @fopen($file,"r+"); //this opens the file
$myCounter = (int)fgets($fp,10000); //
++$myCounter; //
rewind($fp);
fwrite($fp,$myCounter); //this will write the value
fclose($fp);
echo $myCounter; //this shows the value
?>

And save it as counter.php

Then put in the script where you would like the counter to go!

<?
include("counter.php");
?>

Make sure these are in the same folder on your FTP, and chmod the file counter.txt to 777.

Redirecting

Simple tutorial that will redirect your user to any page:

Just insert this script where you would like it to show in your .php file:

<?php
header("Location: http://new.url/goes/here");
?>

Browser Type

Show your browser:just insert this script where you would like it to show in your .php file:

<?php
echo $_SERVER['HTTP_USER_AGENT'];
?>

Related Articles

  • Simple Hit Counter
    Use this simple script for a basic click counter to display the amount of hits to your site.
  • Counter in ASP
    A hit counter is an essential part of a site to know how many people are coming to site. Here is an easy way to make a counter. All you need is access to ASP and be able to give a write access to a directory...
  • Easy Flat File Hit Counter
    Create a very simple hit pageview counter without any database! Use flat file scripting to make an easy counter!
  • JavaScript: Redirecting URL
    Whenever you want to generate dynamic pages you often have to resort to using some server side scripting language such as PHP or ASP
  • PHP Counter
    A counter is a simple yet essential script when developing web pages.
    First of all, we need a file where to store the data ( a simple text file). This file must be CHMODed to 777 (under Linux)
    Lets name this file data.txt. Do not forget to include it into the same directory as the PH...
  • A Nice Hit Counter
    I shows
    Total Hits Unique Hits Todays Hits Todays Unique Hits
  • Hit Counter
    Hit counters are used to track the amount of visitors there have been to a cetain page. I have looked through the internet and I have come up with 2 different ways to produce a hit counter.
  • Redirection
    Have you changed the navigation structure of your website by moving or deleting pages of your site? If a visitor has the old page bookmarked or comes from a link on another site to it, they will receive a 404 error; page can not be found. Solve this by redirecting the visitor to the new page. The me...
  • Outwards Link Counter
    This will allow you to create a script that will count the amount of times a certain link has been clicked and display the results on your page.
  • Download Counter with Apache and PHP
    Info: Collect statistics on the popularity of your downloads with Apaches mod_rewrite and PHP. Some sites present you an URI like Example.com, which is less than perfect. Being a Windows user (well sometimes) I expect that when I add a file to my download manager Ill see the filename in the list.....

Contact Web Design Outsource and get started today

Need Website Designing, Development, Redesigning, Maintenance and SEO services or help growing your company's web presence? Request a free Quote Now.