egturnkey Posted July 29, 2009 Share Posted July 29, 2009 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 <?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."; } ?> config.php <? $dbhost = "localhost"; $dbuser = "username"; $dbpass = "password"; $dbname = "dbname"; @mysql_connect($dbhost,$dbuser,$dbpass); @mysql_select_db($dbname); ?> database.sql 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 Link to comment https://forums.phpfreaks.com/topic/167880-button-with-limited-clicking-2/ Share on other sites More sharing options...
haku Posted July 29, 2009 Share Posted July 29, 2009 Did you write this code? Link to comment https://forums.phpfreaks.com/topic/167880-button-with-limited-clicking-2/#findComment-885524 Share on other sites More sharing options...
xtopolis Posted July 29, 2009 Share Posted July 29, 2009 Two things I saw: 1) $time = date("m/d/y"); 2) $qq = mysql_query("SELECT * FROM ip_table WHERE ip='$_SERVER[REMOTE_ADDR]' AND date='$date'") 2)"date" is a reserved word, the query should come up with an error. 1)if "date" column is a timestamp, I don't expect '$date' to ever match it. Timestamps look like: YYYY-MM-DD HH:MM:SS $date == MM/DD/YY How can TIMESTAMP == $date ? Link to comment https://forums.phpfreaks.com/topic/167880-button-with-limited-clicking-2/#findComment-885527 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.