Free2Code
The majority of forums are now only available as archives, which means posting/editing is disabled.

The Anything and Everything forum is still open.
 
Time: 2013-05-19, 07:51am
Update MySQL
Subject: Update MySQL  ·  Posted: 2006-10-23, 09:57pm
Rank: ? (10)
Member #: 27981
I try to update my users last login date,
but im not able?
Anybody know why?

I run this:

Code:
  1. $date = date('d m, Y');
  2. $sql = mysql_query("UPDATE users SET last_login = '$date' WHERE username = '".$_POST['username']."'")or die(mysql_error());


ofcourse isnt this the whole script, the rest works, but this one dont ;(

» Post edited 2006-10-23, 09:59pm by nukleuz.

---- Nukleuz ---- Newbie ;) thihi
 
  Reply to this ·  Post link ·  Top
Subject: Re: Update MySQL  ·  Posted: 2006-10-24, 01:53am
Rank: ? (768)
Member #: 11085
I can't see any errors with your script at first glance, though that may simply be because I just awoke. Nonetheless, I must ask if that particular script generates any errors (and before you answer, be sure that errors are turned on in php.ini).

I can, however, see multiple problems with your script. First of all, you are much better off storing the result of the time() function in the database and calling the date(string format [, int timestamp]) function using it later. This allows you to eventually give users the option to set their own format for the date function, as well as their own offset to the time (offset from GMT where they live). Furthermore, if users have passwords, it would be wise to check them as well as the username whenever running any Mysql query which modifies the user table. This may come as a surprise to you, but it is unspeakably easy to modify $_GET variables, simple to modify $_COOKIE variable, and not too hard to modify $_POST variables on the users end, therefore, your current system allows any user to act as any user if so they wish.

» Post edited 2006-10-24, 04:13am by relpats_eht.

- relpats_eht
 
  Reply to this ·  Post link ·  Top
Subject: Re: Update MySQL  ·  Posted: 2006-10-24, 02:36am
Rank: ? (4827)
Member #: 3416
you are much better off storing the result of the time() function in the database and calling the string date(string format [, int timestamp]) function using it later

i strongly agree with this statement.

my mind is like a steel trap! it only hangs on to the big stuff. visit my forums at track7.org
 
  Reply to this ·  Post link ·  Top

Pages: 1

Please login or register to post a reply.

Penguino AVR

Want to learn about robotics or microcontrollers?
Check out the Penguino AVR from our friends at
Icy Labs