Chcę wam sie poradzić w jednej rzeczy. Zrobiłem taki plik wylogowania i chciałbym aby zapisywał datę jego wylogowania w kolumnie endlogin. Wiem że muszę tu update napisać
tylko jak? Jest jeszcze plik login.php w którym owszem zapisuje datę logowania ale może tu jest jeszcze opcja żeby zapisywał datę ostatniego logowania w kolumnie endlogin.
login.php [php] <?php require_once('Connections/local.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": break; case "double": break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $query_Login = "SELECT * FROM userlogin"; ?> <?php // *** Validate request to login to this site. } $loginFormAction = $_SERVER['PHP_SELF']; $_SESSION['PrevUrl'] = $_GET['accesscheck']; } $loginUsername=$_POST['UserName']; $password=$_POST['Password']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "profile.php"; $MM_redirectLoginFailed = "register.php"; $MM_redirecttoReferrer = false; $LoginRS__query=sprintf("SELECT username, password FROM userlogin WHERE username=%s AND password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); if ($loginFoundUser) { $loginStrGroup = ""; //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; $ip = $_SERVER['REMOTE_ADDR']; $update = "UPDATE userlogin SET lastlogin = NOW() , lastip = '$ip' WHERE username = '$loginUsername'"; $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } } else { } } ?>
logout.php
<?php require_once('Connections/local.php'); ?> <?php // *** Logout the current user. $logoutGoTo = "index.php"; } $_SESSION['MM_Username'] = NULL; $_SESSION['MM_UserGroup'] = NULL; exit; } ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": break; case "double": break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $query_Recordset1 = "SELECT * FROM userlogin"; ?>
Mam takie zapytanie czy ciężko jest tu komuś podpowiedzieć? Wiem tylko tyle że można to zapisać w sesji a potem to wyświetlić tylko nie wiem w którym miejscu dac zmienne sesji na lastlogin i potem je wyświetlić. Może jeszcze dam plik profil.php pozdrawiam