jdock1 Posted August 1, 2009 Share Posted August 1, 2009 Im trying to code an include file that when the user visits the page after three times, it echos an error message stating that the page has been accessed to many times. It would just go by IP address and then let the user back the next day. It could either go by a cookie or IP, whatever is easier. Could anybody give me a tip? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/168342-how-could-i-restrict-access-to-a-page-after-so-many-pageviews/ Share on other sites More sharing options...
.josh Posted August 1, 2009 Share Posted August 1, 2009 don't even bother with the cookie option. People can erase those in like half a second. Even average joe knows how to do that. IP checks aren't really that much harder to get around, either, but it's the lesser of the two evils. Ideally you should install a login/membership system and force the users to login to get to the page, and then have a counter in their account. Quote Link to comment https://forums.phpfreaks.com/topic/168342-how-could-i-restrict-access-to-a-page-after-so-many-pageviews/#findComment-888045 Share on other sites More sharing options...
jdock1 Posted August 1, 2009 Author Share Posted August 1, 2009 don't even bother with the cookie option. People can erase those in like half a second. Even average joe knows how to do that. IP checks aren't really that much harder to get around, either, but it's the lesser of the two evils. Ideally you should install a login/membership system and force the users to login to get to the page, and then have a counter in their account. Thanks, thats the structure I planned, but Im still pretty new to the databases. How should I structure the DB? Quote Link to comment https://forums.phpfreaks.com/topic/168342-how-could-i-restrict-access-to-a-page-after-so-many-pageviews/#findComment-888101 Share on other sites More sharing options...
YourNameHere Posted August 1, 2009 Share Posted August 1, 2009 You could have a relative table that has as many fields as you have restricted pages. You would then add a username column (or IP if you must use that instead). When they access that page, your script could then increment the corresponding column by one. You could also at a last accessed column next to each page column and that way if you wanted to add the functionality to view only so many times per day etc... Quote Link to comment https://forums.phpfreaks.com/topic/168342-how-could-i-restrict-access-to-a-page-after-so-many-pageviews/#findComment-888112 Share on other sites More sharing options...
onenonly Posted August 1, 2009 Share Posted August 1, 2009 don't even bother with the cookie option. People can erase those in like half a second. Even average joe knows how to do that. IP checks aren't really that much harder to get around, either, but it's the lesser of the two evils. Ideally you should install a login/membership system and force the users to login to get to the page, and then have a counter in their account. Thanks, thats the structure I planned, but Im still pretty new to the databases. How should I structure the DB? id views ip every time user visit the page get their ip by using $_SERVER['REMOTE_ADDR'] then add their ip to database plus add increment to their view if ($row['views'] > 3){ do this }else{ add ip and views to database } Quote Link to comment https://forums.phpfreaks.com/topic/168342-how-could-i-restrict-access-to-a-page-after-so-many-pageviews/#findComment-888116 Share on other sites More sharing options...
bundyxc Posted August 1, 2009 Share Posted August 1, 2009 In the future, you'll need this for the MySQL counter: 'UPDATE table SET counter=counter+1 WHERE ip=' . $_SERVER['REMOTE_ADDR'] I believe that this is correct, anyhow.. Quote Link to comment https://forums.phpfreaks.com/topic/168342-how-could-i-restrict-access-to-a-page-after-so-many-pageviews/#findComment-888222 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.