1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//source - http://www.stevedawson.com/scripts/text-counter.php
<?php
$log_file = "count_file.txt";
if (file_exists($log_file))
{
$fil = fopen($log_file, 'r');
$dat = fread($fil, filesize($log_file));
echo $dat+1;
fclose($fil);
$fil = fopen($log_file, w);
fwrite($fil, $dat+1);
}
else
{
$fil = fopen($log_file, 'w');
fwrite($fil, 1);
echo '1';
fclose($fil);
//only admin can read&write
chmod($log_file, 0600);
}
?>
store data with commas!! ```js //test.html
1
2
3
4
5
6
7
8
9
10
11
12
function revalidate(){
var fname = $("[name=fname]").val();
var email = $("[name=email]").val();
var dob = $("[name=dob]").val();
if (fname.indexOf(",")>-1 || email.indexOf(",")>-1 || dob.indexOf(",")>-1){
alert("Commas not allowed");
return false;
}
else
return true;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
```js
//subscribe.php
<?php
if (!isset($_POST["fname"]) || !isset($_POST["email"]) || !isset($_POST["dob"]) || !isset($_POST["country"]))
{
die("error 1x082347");
}
$line = $_POST["fname"].",".$_POST["email"].",".$_POST["dob"].",".$_POST["country"]."\n";
$log_file = "count_file.txt";
if (file_exists($log_file))
{
//append
$fil = fopen($log_file, 'a');
fwrite($fil, $line);
fclose($fil);
}
else
{
$fil = fopen($log_file, 'w');
fwrite($fil, $line);
fclose($fil);
//only admin can read&write
chmod($log_file, 0600);
}
?>
origin - http://www.pipiscrew.com/?p=3151 php-plain-visitor-counter