Skip to main content
November 30, 2009
Question

Login with timestamp

  • November 30, 2009
  • 1 reply
  • 771 views

I use dreamweaver's Login behavior and would like to add a timestamp into the database table. So if someone logs in, the current date will be inserted into the table. I have no success in combining the login and the update database behavior. Could someone show me the way?

Leolux

This topic has been closed for replies.

1 reply

Waleed Barakat
Known Participant
December 1, 2009

Hi,

You can insert the current timestamp that only matches the PhpMyadmin db when uses Dreamweaver by adding this value to the column that stores the login_date as follow:

In the registration form select the date field and set it`s value to whether to hidden or default value to:

<input type="hidden" name="date_gs" value="<?php $now = date('Y-m-d-H:i:s'); echo $now; ?>" />

Also see the attahements to see how i added the current date_time to my db field.

Open the attachements...

__
Best Regards
Waleed Barakat
Developer-Online Creator and programmer

December 1, 2009

Thank you for your input, Waleed.

In the source code I have this:

if (isset($_POST['username'])) {
  $loginUsername=sha1($_POST['username']);
  $password=sha1($_POST['password']);
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "welcome.php";
  $MM_redirectLoginFailed = "login.php";
  $MM_redirecttoReferrer = false;

Would that be the right place to put in the update behavior? Or should I put it under that code?

  if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];   
    }
    header("Location: " . $MM_redirectLoginSuccess );

Regards

Leolux

Waleed Barakat
Known Participant
December 1, 2009

Hi, actually it won`t work that way, i think it will need more work to do that just entering the current date value!

The work should be done:


#1: You have to create another table in your database to store recent login information.

a) this table structure is:

- Primary_key = ID

- Foreign_key = Current Login Member ID {$_SESSION['kt_login_id']}

- Last Login Date = you can use the default value mentioned before = <?php $now = date('Y-m-d-H:i:s'); echo $now; ?>

- IP Address = REMOTE_ADDR

#2: Apply an insert transaction or custom_trigger "if required" to insert the above information into the new created table depending on the current logged in user ID which is: $_SESSION['kt_login_id'] 

__
Best Regards
Waleed Barakat
Developer-Online Creator and programmer