Hello, I am a midlevel PHP developer building an ecommerce site. I am adding a module that allows the admin to view registered customers and the time and date they last logged in. The date/time is inserted into the 'customers' table, in a datetime column. When the customer logs in, this information is UPDATED in the database along with the cookie setting. The UPDATE works fine and is inserted into the customer's datetime column. However, when I test it with another customer account, the previously logged in customer has their table updated back to the 0:00:00 datetime default. The default field is empty on the database, so that is not selected. The UPDATE is written as: sql = "UPDATE customers SET loggedin = NOW() WHERE email='$email'"; (rest of query goes here). I have also tried creating a date variable with a date function with the same results. ($date = date(params here)) My first guess is the cookie is still recognizing the logged in email account. But if so, why would it UPDATE back to zero. It should not update at all, leaving the datetime in place so the admin can view this information. Of course, when the customer logs in again, the new datetime will reflect that as well. I have tried the update on the redirect page, after the cookie is set, by grabbing the customer's ID and updating then. Still the same result. I hope this is clear and I thank you all for your assistance.
hello my friend, try sql query like that "UPDATE customers SET loggedin = NOW() WHERE email='".$email."'" I usually use this style. I hope it works.
Why dont you just use a timestamp string instead of a datetime. I usually use datetimes but a strtotime works good also. $time = strtotime('now'); $query = "UPDATE customers SET loggedin = '".$time."' WHERE email='".$email."'"; Let me know if that helps. Kinda hard to understand your post.