Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Logging User access

Engaged ,
Dec 12, 2006 Dec 12, 2006

Copy link to clipboard

Copied

LAMP system DWMX 6.1

I have a table "USERS" which contains, as you'd expect, User, password, accesspermissions. This I use for controlling access.

I have also added a new column of lastaccessed.

What I am trying to acheive is a timestamp on first login but I'm not sure how to go about this.

I attach the login code block for ref.

<form ACTION="<?php echo $loginFormAction; ?>" method="POST" name="form1" onSubmit="YY_checkform('form1','Username','#q','0','* Username field cannot be empty *','Password','#q','0','* Password field cannot be empty *');return document.MM_returnValue">
<p align="center"><font face="Arial">Username
<input name="Username" type="text" id="Username">
</font></p>
<p align="center"><font face="Arial">Password
<input name="Password" type="password" id="Password">
</font></p>
<p align="center"><font face="Arial">
<input type="submit" name="Submit" value="Login">
</font></p>
</form>
TOPICS
Server side applications

Views

315
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 12, 2006 Dec 12, 2006

Copy link to clipboard

Copied

I'm not sure from your post whether or not you are using PHP and MySQL, but if you are, I suppose that upon successful login you could capture the current UNIX date/timestamp value by doing something like $rightnow = mktime();

Then perform a SQL update of the lastaccessed column of the user's record in the USERS table and store the value of $rightnow in that column. $rightnow would be a ten-digit value. To format that value as a human-readable date and time, you could use the PHP getdate( ) function. As an alternative, you could use the MySQL now() function to insert the current date and time (in a different format).

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 13, 2006 Dec 13, 2006

Copy link to clipboard

Copied

Thanks for this

I'm running on LAMP (Linux, Apache, MySQL, PHP)

I have set the main "lastaccessed" column via myphpadmin to timestamp format but am still quite new at coding so will need some help with the code and positioning. (Use DW to construct the code - lazy I know but I'm short on time!)

I would think it would go something like this...


if (isset($HTTP_POST_VARS['Username'])) {
$loginUsername=$HTTP_POST_VARS['Username'];
$password=$HTTP_POST_VARS['Password'];
$MM_fldUserAuthorization = "ACCESSPERM";
$MM_redirectLoginSuccess = "/loginsuccess.htm";
$MM_redirectLoginFailed = "/loginfailed.php";
$MM_redirecttoReferrer = false;
$updateSQL = sprintf("UPDATE DBUSERS SET LASTACCESSED=%s",
GetSQLValueString($HTTP_POST_VARS['nowdatefield'], "text"));
mysql_select_db($database_dbcrm1, $dbcrm1);

$LoginRS__query=sprintf("SELECT USER, PASSWORD, ACCESSPERM FROM DBUSERS WHERE USER='%s' AND PASSWORD='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));

$LoginRS = mysql_query($LoginRS__query, $dbcrm1) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {

$loginStrGroup = mysql_result($LoginRS,0,'ACCESSPERM');


Probably way off but at least I'm trying!

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 13, 2006 Dec 13, 2006

Copy link to clipboard

Copied

LATEST
lol - no.. it was completely wrong!!

to make life easier for myself, I have created another php page which the user goes to on successful login.

This then creates the variables as you have suggested and then auto re-directs.

Many thanks for your help

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines