Jump to content

How could I restrict access to a page after so many pageviews?


Recommended Posts

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

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. 

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?

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...

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

 

}

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.