Class Problem
Posted: Wed Jan 22, 2003 6:46 am
Well, its a function in the class anyways.
heres the function.
ok now when i use the login form and enter my username andpass, it says:
Couldnt Start New Session.
This is how its called:
Its wierd because:
That actually gets recorded into the log table. Which means the function is working properly but there is something after that which is not creating the session.
?>[/quote]
heres the function.
Code: Select all
<?php
function StoreSession( $strUserID = 0, $strUserName = "", $intSecurity = 0, $strArray = "" )
{
session_start();
$Database = new Database();
@$SvrConnection = mysql_connect( $Database->strHost, $Database->strUser, $Database->strPass );
if ( $SvrConnection )
{
// Connected to the Database OK
$DBConnection = mysql_select_db( $Database->strData, $SvrConnection );
if ( $DBConnection )
{
$FieldNames = explode( ",", $this->__ExtraFieldNames );
$FieldNameValue = explode( ",", $strArray );
$strQuery = "INSERT INTO {$this->__StoreSessionTableName} ";
$strQuery .= "( '{$this->__FieldNameSession}','{$this->__FieldNameUser}','{$this->__FieldNameSecurity}','{$this->__FieldNameUserID}' ";
$i = 0;
foreach( $FieldNames as $name=>$value )
{
if ( $value <> "" )
{
$strQuery .= ",'$value'"; $i++;
}
}
$strQuery .= ") VALUES ('" . session_id() . "','$strUserName','$intSecurity','$strUserID'";
$e = 0;
foreach( $FieldNameValue as $name=>$value )
{
if ( $i > $e )
{
$strQuery .= ",'$value'"; $e++;
}
}
$strQuery .= ")";
$result = mysql_query( $strQuery );
if ( $result )
{
// Connection to Database Failed
return true;
}
else
{
// Connection to Database Failed
return false;
}
}
else
{
// Connection to Database Failed
return false;
}
}
else
{
// Connection to Database Failed
return false;
}
}
?>Couldnt Start New Session.
This is how its called:
Code: Select all
<?php
}
function ProcessLogin()
{
global $dtlsSecurity;
$strUser = @$_POST['struName'];
$strPass = md5( $_POST['strPass'] );
$Database = new Database;
@$SvrConnection = mysql_connect( $Database->strHost, $Database->strUser, $Database->strPass );
if ( $SvrConnection )
{
// Connected to the Database OK
$DBConnection = mysql_select_db( $Database->strData, $SvrConnection );
if ( $DBConnection )
{
$strQuery = "SELECT * FROM users ";
$strQuery .= "WHERE username = '$strUser' ";
$strQuery .= "AND password = '$strPass' ";
$results = mysql_query( $strQuery );
$result = mysql_fetch_row( $results );
if ( $result )
{
// Write to the log file
$strLog = "Login OK: {$result[1]}, {$result[3]}, {$result[4]}, {$_SERVER['REMOTE_ADDR']}, " . date("d/m/Y h:i:m A");
$dtlsSecurity->AddLog( $strLog );
if ( $dtlsSecurity->StoreSession( $result['userid'], $result['username'], $result['level'], "{$result['firstname']},{$result['lastname']}" ) )
{
?>
You have now logged in.
<?php
}
else
{
?>
Couldn't start new session:<br><br>
<a href="javascript:history.go(-1)">Go Back</a>
<?php
}
}
else
{
$strLog = "Login Failed: $strUser, $strPass, {$_SERVER['REMOTE_ADDR']}, " . date("d/m/Y h:i:m A");
$dtlsSecurity->AddLog( $strLog );
?>
Login Failed<br><br>
The login details that you have entered are incorrect. Please use the link below to go
back and check your username and password again.<br><br>
<a href="javascript:history.go(-1)">Go Back</a>
<?php
}
}
else
{
$strLog = "Database Error: Login, $strUser, $strPass, {$_SERVER['REMOTE_ADDR']}, " . mysql_error() . ", " . date("d/m/Y h:i:m A");
$dtlsSecurity->AddLog( $strLog );
?>
Database Error<br><br>
<a href="javascript:history.go(-1)">Go Back</a>
<?
}
}
else
{
$strLog = "Database Server Error: Login, $strUser, $strPass, {$_SERVER['REMOTE_ADDR']}, " . mysql_error() . ", " . date("d/m/Y h:i:m A");
$dtlsSecurity->AddLog( $strLog );
?>Its wierd because:
Code: Select all
// Write to the log file
$strLog = "Login OK: {$resultї1]}, {$resultї3]}, {$resultї4]}, {$_SERVERї'REMOTE_ADDR']}, " . date("d/m/Y h:i:m A");
$dtlsSecurity->AddLog( $strLog );?>[/quote]