简体   繁体   中英

How to count the number of times a non-registered User presses “Search”, then save it in MySQL database and limit that number for every user?

So I'm working on a website which brings up movie/tv-show posters on clicking "search". Now I'm wondering how can I limit the search button for non-users to 10-15 searches and have unlimited searches for registered users. Think of it like a premium membership sorta deal where the people who pay, get the extra-clicks and people who're using the trial product, get only 10 clicks. What I want to ask is, how do I log the number of times a non-registered user uses the search engine and how do I put a cap on it? And remove that cap for registered users.So please let me know where I can start from.

cheking the number of clicks of each ip adress is not bad idea but it wont solve the problem beacause if the user restart the modem he ll get new ip adress. in my opinion, you can make all users need an account to use the search option and do your check according to that, if the user want to search more than 10-15 searches he/she need to get premium account.

Wow this awesome I usually find app that limits visitors but after they make free account then they reach the limit after that they should pay to have premium account without limits

But any way that can be achieved easy I will explain without codes cause it needs long run

First you should create function to retrieve users IP address so you may use remote_addr or http_forward in case of you use proxy

Second go to database and create table called Ip_users or whatever you need This table should have 2 column. Ip column and id_hash column now you should set ip_column as varchar and id_hash as init

Third is most easy step make Ajax script that take the ip value that we get above in first step and send it to .php script call it uservalid.php as example

Fourth. Uservalid.php should first select count of records for ip if it null it make insert for new ip if it more than zero it update ip_hash + 1 If ip_hash equals 10 it make redirect to account page

This why you need index on IP address column and this is general steps

Maybe free account as start with limits then premium account is better

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM