Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7896545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:55:19+00:00 2026-06-03T07:55:19+00:00

I am coding a script, that will restrict multiple access for a particular user

  • 0

I am coding a script, that will restrict multiple access for a particular user from a given IP address. In other words, a given user will only be able to access/view the page one time from the same IP address.

But how do I compare the incoming IP’s to detect this kind of access?

I want to Track IPs for 60 days max.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:55:20+00:00Added an answer on June 3, 2026 at 7:55 am

    You’ll need to store IPs in a database or flat file somewhere for comparison.

    Let’s imagine you have a MySQL table visits such as this:

    `ip` varchar(255) NOT NULL,
    `date_created` datetime NOT NULL,
    `last_visit` datetime NOT NULL,
    `visits` int(255) NOT NULL,
    PRIMARY KEY (`ip`)
    

    Using PHP we can get the user’s IP, create or update a table record in the database, and then do some comparison.

    <?php
    
    // Get the user's IP
    $ip = getenv('REMOTE_ADDR');
    
    // Create a database record, or update if they're been here before
    $dblink = mysql_connect( 'localhost', 'username', 'password' );
    mysql_select_db( 'database', $dblink );
    $rs = mysql_query( "INSERT INTO visits (ip, date_created, last_visit, visits) VALUES( '$ip', NOW(), NOW(), 1 ) ON DUPLICATE KEY UPDATE `last_visit` = NOW(), visits=visits+1 ", $dblink );
    
    // Compare database record for last visit and first visit
    $rs = mysql_query( "SELECT visits, DATEDIFF( last_visit, date_created ) as sincelast FROM visits WHERE `ip` = '$ip' ");
    $row = mysql_fetch_assoc( $rs );
    
    // If this is their first visit, do one thing, otherwise, do another.
    if ( $row['sincelast'] > 59 || $row['visits'] < 2 ) {
        // They visited 60+ days ago, or this is their first visit
    } else {
        // This is not their first visit
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently coding a simple search script in PHP that requires three variables from
Im working on a script that will pull a variable from my MySQL db
I'm looking for a script/tool that can be customized to check and enforce coding/naming
I am coding a script in which the user selects a range of data,
I'm hacking together a simple php script that will build a list of photo
I have been given a task to create a Python file that will take
I'm trying to implement some kind of caching in a PHP script that will
I came across a confusing fact during coding a script. How can i find
Coding footer naively, if there's not enough content, then there will be empty space
While coding python I'm using only 2 spaces to indent, sure PEP-8 really recommend

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.