egturnkey Posted July 26, 2009 Share Posted July 26, 2009 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 per person ( IP ) , 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 day , per person ( IP ) after the clicking 20 times , it gives msg says for example " come back 2morrow " It is 20 times per person per day just like some downloading websites, when you downloads many files after for example 20 downloads it gives you msg " no more download for you today " so it is yes as you've said 20 times per person per day i've tried to find any script has such function so i can isolate the code but i didn't find any , so i hope if someone can help me about that , making it as simple as it could thanks in advance 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 Link to comment https://forums.phpfreaks.com/topic/167488-click-on-the-button-for-limited-times/ Share on other sites More sharing options...
phpretard Posted July 26, 2009 Share Posted July 26, 2009 Not tested but should give you an idea... <?php if (isset($_POST['submit'])){ //connect to the DB $get_ip=mysql_query("select * from ip_table where ip='".$_POST['clicker']."' "); $num_rows = mysql_num_rows($get_ip); if ($num_rows > 19){ $disable="disabled"; $alert="<script>alert('You are hurting my clicker')</script>"; }else { // $count_a=query the db for the ip and the count $count=$count_a + 1; $insert=mysql_unbuffered_query("update ip_table set count='$count' where ip='".$_SERVER['REMOTE_ADDR']."' "); } mysql_free_result($get_ip); } ?> <form> <input type="hidden" name="clicker" value="<? echo $_SERVER['REMOTE_ADDR']; ?>" /> <input type="submit" name="submit" <? echo $disable; ?> /> </form> <? echo $alert; ?> Link to comment https://forums.phpfreaks.com/topic/167488-click-on-the-button-for-limited-times/#findComment-883196 Share on other sites More sharing options...
egturnkey Posted July 26, 2009 Author Share Posted July 26, 2009 Not tested but should give you an idea... I've test it and it is working thanks very much , but this act as 20 clicks per IP how can i make it 20 clicks per IP per 24 hours means that the same person can click 20 times each 24 hours i guess it may need a command to be added to cronjob is there any chance it be 20 clicks per ip per 24 hours thanks so much for your time , it really helps me so much Link to comment https://forums.phpfreaks.com/topic/167488-click-on-the-button-for-limited-times/#findComment-883221 Share on other sites More sharing options...
egturnkey Posted July 26, 2009 Author Share Posted July 26, 2009 a friend of mine given me that query in order to make it 20 click per IP per 24 hours so how can i use it with your code, can you please write it upon that update if it was right $todayis = date('Y-m-d'); $query = " SELECT COUNT(`ip`) from `clicks` WHERE `date` = '$todayis' "; thanks so much Link to comment https://forums.phpfreaks.com/topic/167488-click-on-the-button-for-limited-times/#findComment-883263 Share on other sites More sharing options...
vineld Posted July 26, 2009 Share Posted July 26, 2009 You need to add a date field to the database as well and then either use one count for each date or simply update accordingly when you encounter the next day. Link to comment https://forums.phpfreaks.com/topic/167488-click-on-the-button-for-limited-times/#findComment-883268 Share on other sites More sharing options...
egturnkey Posted July 26, 2009 Author Share Posted July 26, 2009 okay here is an simple example of database.sql ( ip / time ) config.php ( connection to database ) index.php ( main functions ) download --------- http://www.egcss.com/example.rar 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 Link to comment https://forums.phpfreaks.com/topic/167488-click-on-the-button-for-limited-times/#findComment-883452 Share on other sites More sharing options...
allin44 Posted July 26, 2009 Share Posted July 26, 2009 if you are still having issues with the time you could just do $back = strotitme("now - 24 hours"); select * from table where ip = $userip and times > $back Link to comment https://forums.phpfreaks.com/topic/167488-click-on-the-button-for-limited-times/#findComment-883459 Share on other sites More sharing options...
egturnkey Posted July 26, 2009 Author Share Posted July 26, 2009 thanks but it isn't matter of time the example will shows the error needs to be fixed database.sql ( ip / time ) config.php ( connection to database ) index.php ( main functions ) download --------- http://www.egcss.com/example.rar Link to comment https://forums.phpfreaks.com/topic/167488-click-on-the-button-for-limited-times/#findComment-883490 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.