PHP is open source scripting language. It\'s widely used to develop web applications.  Home Web Programming PHP Simple Counter & Redirecting & Browser Type
Your Ad Here

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'];
?>


Author's URL: Andy
Thank you for voting.
Rate this Materials:
Bad 
1 2 3 4 5 Excellent
print this page subscribe to newsletter subscribe to rss

Web programming � everything from the basics of visual design and architecture to the specifics of applications, graphics, and scripting. More Web Programming: Most Popular Materials | Fresh Materials | More PHP Tutorials at LearnPHP.org

Add comments to "Simple Counter & Redirecting & Browser Type"

Only registered users can write comment

Reader's comments