PDA

View Full Version : Login Script


mcoelho123
05-17-2006, 12:12 PM
How can i do not using cookies but using PHP and MySQL to make a script that when a user after making a login it shows a last visited state, like:

You last visited: 11 Hours Ago at 12:48 AM

Thanks in advance

degsy
05-17-2006, 02:38 PM
Here is a full login system
http://www.evolt.org/article/PHP_Login_System_with_Admin_Features/17/60384/index.html

It has a timestamp in the user login so you can compate with that against the current time.

mcoelho123
05-17-2006, 03:01 PM
It returns the following error:

Something went wrong while creating tables. Please, delete all tables in database.
1214: The used table type doesn't support FULLTEXT indexes

With no tables

TopFighter
05-18-2006, 10:35 AM
you can, at your login script, where the data is beeing verified, before it wis put in the mysql tables, - get the time of loging in by using time();
when the data is verified and ok, put all data in mysql tables, also have a field containing, lastlogintime.

then with the next login, you can compare to that time again, echoing the difference between the to, and after that update the value to the new time (to compare next time)

mcoelho123
05-18-2006, 04:30 PM
you can, at your login script, where the data is beeing verified, before it wis put in the mysql tables, - get the time of loging in by using time();
when the data is verified and ok, put all data in mysql tables, also have a field containing, lastlogintime.

then with the next login, you can compare to that time again, echoing the difference between the to, and after that update the value to the new time (to compare next time)

Can you explain better im new to this,
Even if i do it shows the time that i login not lasttime i think.
How can i do the compare?

Thanks

guelphdad
05-18-2006, 05:58 PM
Are you using that script with or without modifications? you want to check the time against the users table for initial login time, against the active_users or active_guests table for last activity.

also for the note above with the error message about fulltext indexing, you can't use fulltext indexes on innodb table types, only the myisam table type supports it.

mcoelho123
05-18-2006, 06:15 PM
Im using this script:

<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['Username'])) {
$loginUsername=$_POST['Username'];
$password=$_POST['Password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "contactos.php";
$MM_redirectLoginFailed = "default.php?login=failed";
$MM_redirecttoReferrer = false;
mysql_select_db($database_MyCon, $MyCon);

$LoginRS__query=sprintf("SELECT Username, password FROM members WHERE Username='%s' AND password='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));

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

//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;

if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
$today=date("Y-m-d H:i:s");
$query="UPDATE Members SET LastVisit='$today()'";
$result=mysql_query($query) or die ("Erro na BD");
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>

And whats the difference of InnoDB and miSAM?