CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 trouble creating security log of logins

Print topic Send  topic

Author Message
donsafar


Posts: 90
Posted: 04/06/2004, 7:30 PM

I am trying to log each time a user logs in to the system. The code in the Login button onclick event is as follows:

//Login @4-2D60E460
global $Login;
if(!CCLoginUser($Login->login->Value, $Login->password->Value))
{
$Login->Errors->addError("Login or Password is incorrect.");
$password = $Login->password->Value;
$Login->password->SetValue("");
$Login_DoLogin_OnClick = false;
$success = "0"; //login failed
}
else
{
$password = $Login->password->Value;
$success = "1"; //login passed
}

$user = $Login->login->Value;
$ip = getenv("REMOTE_ADDR");
$SQL = "Insert into tblSecurityLog (LogUser_Login, LogUser_Password,LogSuccessful,LogIP) ";
$SQL .= " VALUES ('$user','$password', '$success', '$ip')";
$db = new clsDBCAPDB();
$db->query($SQL);
unset($db);

//End Login

If the login fails (bad user login or password) a record gets inserted. If the login succeeds, no record is built. Any ideas what I am doing wrong?
_________________
Don Safar
View profile  Send private message
lvalverdeb

Posts: 299
Posted: 04/08/2004, 4:32 AM

Hi Don,

You've probably fixed the problem by now. Just in case, I am positive that the reason why the record is inserted regardless of whether the login is successfull or not is because of the closing bracket in the else statement which belongs at the end of your custom script right after unset($db) (or $db->close() ;-) )

Luis

_________________
lvalverdeb
CR, GMT-6
XAMPP/Ubuntu/CCS3.2/4
View profile  Send private message
Don Safar
Posted: 04/08/2004, 8:14 AM

Actually I want it to track both successful and unsuccessful login attempts
($success set to either 0 or 1). The problem is with the unset($db) command.
When I changed it to $db->Close(), the script performed as expected. This
seems to be a problem only with PHP and Access as the script works fine when
using PHP with either MySQL or MS SQL as the backend.

"donsafar" <donsafar@forum.codecharge> wrote in message
news:5407367ca809d4@news.codecharge.com...
> I am trying to log each time a user logs in to the system. The code in the
Login
> button onclick event is as follows:
>
> //Login @4-2D60E460
> global $Login;
> if(!CCLoginUser($Login->login->Value, $Login->password->Value))
> {
> $Login->Errors->addError("Login or Password is incorrect.");
> $password = $Login->password->Value;
> $Login->password->SetValue("");
> $Login_DoLogin_OnClick = false;
> $success = "0"; //login failed
> }
> else
> {
> $password = $Login->password->Value;
> $success = "1"; //login passed
> }
>
> $user = $Login->login->Value;
> $ip = getenv("REMOTE_ADDR");
> $SQL = "Insert into tblSecurityLog (LogUser_Login,
> LogUser_Password,LogSuccessful,LogIP) ";
> $SQL .= " VALUES ('$user','$password', '$success', '$ip')";
> $db = new clsDBCAPDB();
> $db->query($SQL);
> unset($db);
>
> //End Login
>
> If the login fails (bad user login or password) a record gets inserted. If
the
> login succeeds, no record is built. Any ideas what I am doing wrong?
> _________________
> Don Safar
> http://www.insights-web.com
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>


Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.