473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Need Help For Last Visit

52
Hi all , I need help on how to do a last visit update to find the previous login date and time of the user.
Jul 23 '07 #1
8 1519
abertay
10
Hi all , I need help on how to do a last visit update to find the previous login date and time of the user.

You can do that with the help of Cookies.
Jul 23 '07 #2
chaos
52
You can do that with the help of Cookies.
Gt any example how to use the cookie???
Jul 23 '07 #3
nathj
938 Expert 512MB
Hi all , I need help on how to do a last visit update to find the previous login date and time of the user.
If this is on a system where you store the user details in a database you can also store the date and time of the visit. So when the log in again you can check when they last visited display any information you need to based on that and then log the new visit date and time.

This way doesn't rely on cookies which may be switched off on the user side of things.

This is the way I would do it, as the data is more permanent. Even if the user has cookies on they can clear them out so you loose the information about their last login. Storing it in the database means you have contorol over the data you need.

Cheers
nathj
Jul 23 '07 #4
chaos
52
If this is on a system where you store the user details in a database you can also store the date and time of the visit. So when the log in again you can check when they last visited display any information you need to based on that and then log the new visit date and time.

This way doesn't rely on cookies which may be switched off on the user side of things.

This is the way I would do it, as the data is more permanent. Even if the user has cookies on they can clear them out so you loose the information about their last login. Storing it in the database means you have contorol over the data you need.

Cheers
nathj

wt will be the code like???
Jul 23 '07 #5
nathj
938 Expert 512MB
wt will be the code like???
Hi,

First of all you need a database with a table in it that stores the user credentials.

Second you need a login page. This normally includes a form with a post method. The desitination page, as set by the action on the form, would check the credentials entered are for a valid user and if so when they last logged in. If the credentials are invalid then you need to report in this to the visitor.

Third, based on the the current time and the last logged in time the user who sucesfully logs in can be presented with a specific message. This would go on the the page the login form specifies as the form action.

That's the general principle. I will be doing something like this very shortly but that the design I have mapped out. I am not going to write my module and then give you the code, however if you have a go and post any code you get stuck with I will help out.

It is worth reading through some tutorials on php and database:
Data Abstraction Layer
W3Schools

These are both excellent, I use them all the time.

Cheers
nathj
Jul 23 '07 #6
kovik
1,044 Expert 1GB
A quick way is to make your user table have two more columns for the latest login time and the last login time. Then, you could update it simply whenever users log on:

Expand|Select|Wrap|Line Numbers
  1. mysql_query("UPDATE `user` SET `lastLogin` = `latestLogin`, `latestLogin` = " . date('Y-m-d H:i:s') . " WHERE `username` = '" . $username . "' AND `password` = '" . $password . "';");
  2. if(mysql_affected_rows())
  3. {
  4.     // login credentials were correct
  5. }
Jul 23 '07 #7
chaos
52
A quick way is to make your user table have two more columns for the latest login time and the last login time. Then, you could update it simply whenever users log on:

Expand|Select|Wrap|Line Numbers
  1. mysql_query("UPDATE `user` SET `lastLogin` = `latestLogin`, `latestLogin` = " . date('Y-m-d H:i:s') . " WHERE `username` = '" . $username . "' AND `password` = '" . $password . "';");
  2. if(mysql_affected_rows())
  3. {
  4.     // login credentials were correct
  5. }
In if(mysql_affected_rows())
{
// login credentials were correct
}
wt should i put for the login credentials
Aug 1 '07 #8
chaos
52
how to capture the time when the user login and pass the time into the lastvisit field of the user_profile????
Aug 1 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Gary Stollman | last post by:
My Father is a Clone//ETs plotting to overthrow the human race! On August 19, 1987 a gun-carrying Gary Stollman entered the studio of Los Angeles's KNBC television, crashing consumer reporter...
17
by: Sue | last post by:
<html> Is there someone here that can help me validate the period as the fourth from the last character in an email address. There is other information and validation on the form I have to do but...
5
by: Alistair | last post by:
hi peoples and masterful gurus (a little bit of grovelling never hurt anyone...apart from the sore knees) I'm after a little bit of advice on how to do something. basically a history of the...
16
by: Konrad Viltersten | last post by:
Suppose you got a really long page and you'd like to enable the user (supposedly, there's only one but if it's not to difficult we could extend that to any number) not to have to scroll to the...
1
by: Hajime Kusakabe | last post by:
I made a datagrid and it contains several columns. The number of columns depend on what users select from a dropdown list. Therefore the number of columns changes. I would like to find the last...
7
by: John Paul | last post by:
I'm thinking of building an e-commerce site in php. Anyone got any advice in building one? What is the best way to implement a payment system? Are any legal issues involved? Thanks,
0
by: U S Contractors Offering Service A Non-profit | last post by:
Brilliant technology helping those most in need Inbox Reply U S Contractors Offering Service A Non-profit show details 10:37 pm (1 hour ago) Brilliant technology helping those most in need ...
13
by: thetechturf.com | last post by:
Ok, here's the deal. I need a script written that will: Use a regular HTML page and form (I plan to have this in a small box on all my HTML pages) to submit the information: Username and...
2
by: eloi-ribeiro.blogspot.com | last post by:
Hi, I'm having a problem with a query. I'm running Access 2000 and a table with 35000 rows. The table contains several visits to the spots with a CODE (spot code) and DATE (visit date)...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.