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 7943055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:09:32+00:00 2026-06-04T00:09:32+00:00

I am trying to create a system to store the last logged on IP,

  • 0

I am trying to create a system to store the last logged on IP, and to compare it to the current IP, then do some functions later on down the road, but currently, I cannot compare them without going to the last else statement. Here’s the code.

<?php

$userToPull = $session->userinfo['username'];

$query = "SELECT * FROM users WHERE username='$userToPull'";
            $result = mysql_query($query);      

            while($row = mysql_fetch_row($result)){

                    $userToShow = $row[25];
                    $IPtoVerify = $row[26];

                    }

$lastActivity = RelativeTime($userToShow);
$currIP = $_SERVER['REMOTE_ADDR'];

/*

Shows Partner Stuff

}elseif(!$session->isAdmin()){

echo "<div style='text-align:right;' id='homebox'";
echo "<b>Partner Total:</b> ".$database->getNumMembers()."<br>";
echo $database->num_active_users." partners logged in and ";
echo $database->num_active_guests." guests viewing the site.<br><br>";
echo "</div>";

*/


if(!$IPtoVerify == $currIP){

echo "<div style='text-align:right; background-color: #FAAAB3' id='homebox_partner'";
echo "<b>You are logged on from an unrecognized location.</b><br>";
echo "You will be sent a notification for security purposes.";
echo "<br>This location will automatically be remembered.";
echo "</div><br>";

}elseif($IPtoVerify == $currIP){

echo "<div style='text-align:right;' id='homebox_partner'";
echo "<b>You are logged on from a recognized location.</b><br>";
echo "Your IP is ".$_SERVER['REMOTE_ADDR'];
echo "<br>Your last login was approximately ".$lastActivity;
echo "</div><br>";

}else{

echo "<div style='text-align:right;' id='homebox_partner'";
echo "<b>An error has occurred.</b><br>";
echo "</div><br>";


}

?>

The only thing not working is the if(!$IPtoVerify == $currIP){ if statement.

The IP is stored in the normal fashion, and echo’s like: 100.100.100.100. (normal fashion)

Maybe I am not comparing them right, but it has worked for me in the past.

  • 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-04T00:09:33+00:00Added an answer on June 4, 2026 at 12:09 am

    This code doesn’t do what you think:

    if (!$IPtoVerify == $currIP) {
    

    PHP interprets it as:

    if ((!$IPtoVerify) == $currIP) {
    

    You will want to write it as:

    if ($IPtoVerify != $currIP) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a new System.Threading.Thread object using Jscript, but I can't get
I am trying to create a simple log in system that uses ajax but
I am trying to create a booking system in C#.NET that will store bookings
I am trying to create system configuration for my module.After adding system.xml I'm getting
I'm trying to create a system for representing and designing graphs in an easy
I am trying to create a messaging system between users and organizations - that
I am trying to create a point system in my program similar to stack
I'm trying to create a login system using PHP, and I'm not quite sure
I am trying to create a little ajax chat system (just for the heck
I am trying to create a dynamic pagination system for my website and I've

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.