<?php
$fname = "clicks.txt";
$fsize = filesize($fname);
$fp = fopen($fname, 'r');
$clicks = fread($fp,$fsize);
fclose($fp);
$clicks += 1;
$fp = fopen($fname, 'w+');
fwrite($fp, $clicks);
fclose($fp);
header('Location: http://www.YOUR URL.com');
?>
<?php
$file = 'clicks.txt';
$clicks = file_get_contents($file);
file_put_contents($file, ($clicks+1));
// The rest of your script would go here
// OR to redirect them to the URL:
header("Location: http://www.google.com");
?>
CREATE TABLE clicks` (
`click_id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`click_url` VARCHAR( 1000 ) NOT NULL ,
`click_time` INT( 11 ) UNSIGNED NOT NULL ,
`click_ip` VARCHAR( 16 ) NOT NULL
) ENGINE = MYISAM ;
<?php
$c = mysql_connect('localhost', 'your sql user', 'your mysql pass') or die("Error connecting to mySQL: " . mysql_error());
mysql_select_db('your mysql db') or die("Error selecting database: " . mysql_error());
function smart_quote($q) {
return "'" . mysql_real_escape_string($q) . "'";
}
mysql_query("INSERT INTO `clicks` SET `click_url` = " . smart_quote($_SERVER['REQUEST_URI']) . ",
`click_time` = " . smart_quote(time()) . ",
`click_ip` = " . smart_quote($_SERVER['REMOTE_ADDR'])) or die("Couldn't execute query: " . mysql_error());
?>