Jump to content


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


  • Please log in to reply
5 replies to this topic

#1 Guest_Server Geek_*

Guest_Server Geek_*
  • Guests

Posted 15 May 2006 - 09:55 AM

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

#2 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 15 May 2006 - 02:41 PM

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.

#3 Guest_Server Geek_*

Guest_Server Geek_*
  • Guests

Posted 16 May 2006 - 02:21 PM

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!

#4 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 16 May 2006 - 02:33 PM

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.

#5 Guest_Server Geek_*

Guest_Server Geek_*
  • Guests

Posted 16 May 2006 - 03:12 PM

but the thing is how? i confused..

EDIT: on logout UPDATE users

THANKS!

#6 Alicia

Alicia
  • Members
  • PipPipPip
  • Advanced Member
  • 163 posts

Posted 17 May 2006 - 06:03 AM

[!--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) View Post[/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






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users