Hello dear friends ,

Consider we have a button where you should click

Is there anyone can help me and give the best idea how to make it limited

i means after 20 clicking on that button , it goes de-active / or / image / or / text for example says ( no more clicking )

Yes it could be very complex idea cause it may needs to recall a command at cronjob ( if i'm not wrong )

So the full story :-

i want a button that valid to be clicked 20 times per 24 hours , after the clicking 20 times , it gives msg says for example " come back 2morrow "

thanks in advance and i know it maybe hard and may takes time
but i really with that help , will open a new area into my mind

okay here is an simple example of

database.sql ( ip / time )
config.php ( connection to database )
index.php ( main functions )



but it didn't works cause i've still some error and really not able to understand where to put thay query

$time = time();  
mysql_query("INSERT INTO `ip_table` (`ip`,`timestamp`) VALUES ('".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."',$time)");

so can you please check out the example and fix it

7 Years
Discussion Span
Last Post by BzzBee

Before you read this, please be aware of two things.
1) I have not downloaded your .rar file of code, so my advice may need tweaking to fit in with what you are doing, but hopefully it will still be relevant and helpful.
2) I have not tested this code for validity, because I do not have a valid dataset that I am able to test it on, so there is a slight chance it contains a few syntax errors. Please let me know if it does give errors and I (or some other person on this forum) will try to help.

You would need to have something that reads back from the MySQL and does:
In words: "Count the total number of rows that has the current user's IP address where the time is greater than 24 hours ago"

So the PHP/Mysql for this would be something like

mysql_query("SELECT COUNT(*) as `visits` FROM `ip_table` WHERE `ip` = '".$_SERVER['REMOTE_ADDR']."' AND `time`> '".($time - 86400)."'")

note that `visits` is the number of times the user has visited, so you would then use this like so:

$result = mysql_query("SELECT COUNT(*) as `visits` FROM `ip_table` WHERE `ip` = '".$_SERVER['REMOTE_ADDR']."' AND `time`> '".($time - 86400)."'"); /*note the time is minus 86400 for number of seconds in the day. This would only work if $time represents a certain number of seconds elapsed, such as the unix epoch */

$row = mysql_fetch_array($result);

if($row["visits"] < 20) /* count is less than 20 */
    echo "button here";
else /* count is 20 or greater */
    echo "no more clicking";

one of the easiest way to do that is.

make a field of datatype integer in db table where you are storing any data or information on click. or make a new table for clicks tracking.
at every click increment the existing click value and apply chk if some one click till 20 times from the first click to 20th click with in 24 hours. track time of click as well. see the first time click timing and then check every time click timings if the first time click time plus current click time is less then 24 hours then it should allow to submit. otherwise print a msg come tomorrow.

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.