Damn... 2 posts merged in 1. At the end you find the solution.
Just reposting your code with the PHP tags. Easier to read. ;)
Home.php
PHP Code:
<?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'];
$_SESSION['GuestEMAIL']=$loginUsername;
$password=$_POST['Password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "/Audit_Intro.php";
$MM_redirectLoginFailed = "/Login_Failed.htm";
$MM_redirecttoReferrer = false;
include('Connections/Conex.php');
mysql_select_db($database_Conex, $Conex);
$LoginRS__query=sprintf("SELECT GEMAIL, GPASS FROM guests WHERE GEMAIL='%s' AND GPASS='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
$LoginRS = mysql_query($LoginRS__query, $Conex) 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'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
include('counter.php');
?>
Audit_intro.php
PHP Code:
<?php
//initialize the session
if (!isset($_SESSION))
{
session_start();
session_register();
include('Connections/Conex.php');
}
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "Home.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
include('Connections/Conex.php');
$loginUsername=$_SESSION['GuestEMAIL'];
$GLLI=date("Y-m-d G:i:s");
$_SESSION['GLLI']=$GLLI;
$result=mysql_query("UPDATE guests SET GLLI = '$GLLI' WHERE GEMAIL = '$loginUsername'");
$result = mysql_query("SELECT * FROM guests, projects WHERE GEMAIL='$loginUsername' AND GPJID=PID");
while($row = @mysql_fetch_array($result))
{
$GID=$row['GID'];
$_SESSION['GuestID']=$GID;
setcookie("GuestID","$GID");
$GNAME=$row['GNAME'];
$_SESSION['GuestNAME']=$GNAME;
$PID=$row['PID'];
$_SESSION['ProjectID']=$PID;
setcookie("ProjectID","$PID");
$PNAME=$row['PNAME'];
$_SESSION['ProjectNAME']=$PNAME;
}
?>
Edit:
Instead of
PHP Code:
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
use
PHP Code:
// *** Validate request to login to this site.
session_start();
Likewise in the second script.
Not
PHP Code:
//initialize the session
if (!isset($_SESSION))
{
session_start();
session_register();
include('Connections/Conex.php');
}
but
PHP Code:
//initialize the session
session_start();
include('Connections/Conex.php');