How to limit the records that user can enter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ghjk
    Contributor
    • Jan 2008
    • 250

    How to limit the records that user can enter

    I have php web application and there I have php page for entering stations(Like user). But I want to limit the Number of records. User can only enter the 30 records. How can I limit that?
  • coolsti
    Contributor
    • Mar 2008
    • 310

    #2
    Try to be more specific: Do you want to limit a user from entering more than 30 records at one time? Or do you want to limit a user from entering more than 30 records in total?

    If the first is the case, then you can enforce the limitation using Javascript on your page by disallowing the entry fields to accept more than 30 entries.

    If the second is the case, you can have the PHP scripts query the database for that user to see how many records have already been entered, and if there already are 30 records, the user can be denied access to the input fields to add new records.

    Comment

    • ghjk
      Contributor
      • Jan 2008
      • 250

      #3
      Originally posted by coolsti
      Try to be more specific: Do you want to limit a user from entering more than 30 records at one time? Or do you want to limit a user from entering more than 30 records in total?

      If the first is the case, then you can enforce the limitation using Javascript on your page by disallowing the entry fields to accept more than 30 entries.

      If the second is the case, you can have the PHP scripts query the database for that user to see how many records have already been entered, and if there already are 30 records, the user can be denied access to the input fields to add new records.

      I want to limit a user from entering more than 30 records in total. Database should allow to enter 30 records only.

      Comment

      • coolsti
        Contributor
        • Mar 2008
        • 310

        #4
        I assume that your PHP scripts know who the user is, by means of the user log on ID which is probably stored in as a SESSION variable or somewhere. So when the page is requested which presents the user with the input forms for these records, the script that serves this page should first query the database for how many records this user has already entered. If the number of records is 30, then you just have to have your script not send the input field to the user, but instead a message saying that the user has exceeded his/her limit.

        Comment

        • coolsti
          Contributor
          • Mar 2008
          • 310

          #5
          Actually, what I just wrote in my last reply probably is not robust enough.

          Since the user may be able to use the browser back button or refresh button to show once again the input page even if he/she has already entered 30 posts (assuming you do not have any checks for this situation) then you should also do the following:

          When a user submits an entry, the database should be queried to see how many entries that user already has entered, and if the number is 30, then the insert query should not be processed and instead the user should be presented with a message saying he/she has entered the maximum already.

          Comment

          Working...