Jump to content

Click on the button for limited times


egturnkey

Recommended Posts

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

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;
?>

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  :shrug:

 

 

thanks so much for your time , it really helps me so much

 

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.