Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Controlling number of user searches

Posted on 2008-06-26
5
Medium Priority
?
176 Views
Last Modified: 2013-12-12
hi,

we are adding a php lookup/search feature on our website (lamp).  This feature searches against a single table in a mysql database.

What methods can I use to limit the number of searches performed by users over a period of time e.g. 10mins?  

thanks!
0
Comment
Question by:jrmajor
  • 3
  • 2
5 Comments
 
LVL 2

Expert Comment

by:JurgenvH
ID: 21878677
Do you have registered users who can search or can everybody search who visits the website?
In the last case you'd best track the seaches bij IP-address. Register the searches in a database.
0
 

Author Comment

by:jrmajor
ID: 21878703
my apologies for not adding this information!

no the feature will be available to all users i.e. there are no registered users.
0
 
LVL 2

Expert Comment

by:JurgenvH
ID: 21878771
Then probably the check on IP-address will be sufficient. It probably doesn't matter how many people download from the same computer, they can't work on it at the same time.
$_SERVER['REMOTE_ADDR'] gives you the IP-address, save this in the database with a download counter
0
 

Author Comment

by:jrmajor
ID: 21878820
ok so I would write the ip address to a table and have an autoincrement field to keep track of the number of searches.

what do you think would be best approach for checking the number of searches over a fixed period of time?
0
 
LVL 2

Accepted Solution

by:
JurgenvH earned 750 total points
ID: 21878975
Say you wish max of 5 downloads in 10 minutes.
Every time a download starts you check if the ip is already present in the table. If not:
- write the ipaddress to a table with 1 as no. of downloads and a timestamp.

If the ip address is found, check timestamp to current time. If the difference is less than 10 minutes:
- increment no. of downloads (no change of timestamp)

If the difference is greater than 10 minutes:
- update no. of downloads to 1 and timestamp to current time
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question