Button with limited clicking (2)
Posted: Tue Jul 28, 2009 7:24 pm
Hello friends,
This is the second thread and we almost done 90% of the idea
" consider a button , it must be limited on clicking that button only 20 times per person ( IP ) per day "
which mean if someone click on it 20 times , must wait to next day to click on it more clicks
here is the example to download
( index.php - config.php - db.sql )
http://www.egcss.com/ex2.rar
or reivew the coder as following
index.php
config.php
database.sql
WE STILL HERE ERROR
- It didn't shown the error msg as it should be after the 20 clicking times
however it record in database everything as it should be IP - TIME
so can anyone please check it out and fix it .
thanks in advance
This is the second thread and we almost done 90% of the idea
" consider a button , it must be limited on clicking that button only 20 times per person ( IP ) per day "
which mean if someone click on it 20 times , must wait to next day to click on it more clicks
here is the example to download
( index.php - config.php - db.sql )
http://www.egcss.com/ex2.rar
or reivew the coder as following
index.php
Code: Select all
<?php
include "config.php";
$time = date("m/d/y");
mysql_query("INSERT INTO `ip_table` (`ip`,`timestamp`) VALUES ('".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."',$time)");
$date = date("m/d/y");
$qq = mysql_query("SELECT * FROM ip_table WHERE ip='$_SERVER[REMOTE_ADDR]' AND date='$date'") or die(mysql_error());
$num = mysql_num_rows( $qq ) or die(mysql_error());
if($num > 20) {
echo "You can't click that. You've already clicked it 20 times.";
} else {
echo "You can click that.";
}
?>
Code: Select all
<?
$dbhost = "localhost";
$dbuser = "username";
$dbpass = "password";
$dbname = "dbname";
@mysql_connect($dbhost,$dbuser,$dbpass);
@mysql_select_db($dbname);
?>
database.sql
Code: Select all
CREATE TABLE ip_table (
IP varchar(255),
date varchar(255),
timestamp varchar(255)
) TYPE=MyISAM;
WE STILL HERE ERROR
- It didn't shown the error msg as it should be after the 20 clicking times
however it record in database everything as it should be IP - TIME
so can anyone please check it out and fix it .
thanks in advance