Jump to content

PHP Question - How would you do a last login from IP?


Guest Server Geek

Recommended Posts

Guest Server Geek
Hello Iam hauntmisery and im new to the forums here but i come in peace! hehe.. i need some opions on how to do this. Iam coding a site where i would like to show the user where the last logged in IP was form. Now i could do this with the REMOTE_ADDR fuctions i know that. But its how to get the last logged in to show insted of the 1 that just logged in! Could i use the time fuction to make this work? Thanks for being so nice!

Hauntmisery
Link to comment
Share on other sites

You might have to rephrase your question -- but here goes.

Your question: I want the website to remember who a particular IP address last logged in as, and print that when the IP address returns to log in again.

options:
1. you would need some kind of database / text file to remember who logged in using what IP.
2. you could assume that the same IP address is most likely the same computer and just set a cookie or session variable.
Link to comment
Share on other sites

Guest Server Geek
no it may not be the same PC so i mean like cPanel dose shows you last ip than when you log back in it shows u ur IP!
Link to comment
Share on other sites

Okay, assuming you wrote the login: When they log in, you just record their REMOTE_ADDR to the same database you're storing their login and password to. When they log in, the database is going to open their database record to verify password. Once they're verified, just print the REMOTE_ADDR before recording the new login's REMOTE_ADDR.
Link to comment
Share on other sites

[!--quoteo(post=374298:date=May 16 2006, 10:12 AM:name=Server Geek)--][div class=\'quotetop\']QUOTE(Server Geek @ May 16 2006, 10:12 AM) [snapback]374298[/snapback][/div][div class=\'quotemain\'][!--quotec--]
but the thing is how? i confused..

EDIT: on logout UPDATE users

THANKS!
[/quote]

actually it is pretty simple.. what u need to do is insert a column in db for the ip and update the record everytime username and password matched...

// verify username and password
// record the ip
// update the db
// create a session

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.