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

 CC logout and login issues

Print topic Send  topic

Author Message
2Code

Posts: 24
Posted: 04/12/2014, 9:50 PM

Ok I have a table in row in table users and I am trying to update the table to 1 when user logs in I modified my common php to the following


//CCLoginUser @0-CA04CFE5
function CCLoginUser($login, $password)
{
CCLogoutUser();
$db = new clsDBlocalhost();
$SQL = "SELECT uid, user_level, user_pwd FROM users WHERE username=" . $db->ToSQL($login, ccsText) . " AND user_pwd=" . $db->ToSQL(md5($password), ccsText);
$db->query("UPDATE users SET user_online = '1', LastVisit = Now() WHERE username ='".$login."'");
$db->query($SQL);
$Result = $db->next_record();
if ($Result) {
CCSetSession("uid", $db->f("uid"));
CCSetSession("username", $login);
CCSetSession("user_level", $db->f("user_level"));
CCSetSession("UserAddr", $_SERVER["REMOTE_ADDR"]);
}
return $Result;
}
//End CCLoginUser

How ever it does not update the user_online field to 1 I have been over it a million times but know I am missing something

then I have my cclogout in common to

//CCLogoutUser @0-F63B51EE
$db = new clsDBlocalhost();
$SQL= "UPDATE users SET user_online = '0', logout = Now() WHERE username ='".CCGetSession("username")."'";
$db->query($SQL);

function CCLogoutUser()
{
CCSetSession("uid", "");
CCSetSession("username", "");
CCSetSession("user_level", "");
CCSetSession("UserAddr", "");
}
//End CCLogoutUser

it is suppose to set the user_online to 0 but it is not working either the row remains 0 all the time... am I missing something???

View profile  Send private message
MichaelMcDonald

Posts: 640
Posted: 04/13/2014, 5:09 PM

I haven't gone through all your code but looks like there's a few too many of these "

In this:

WHERE username ='".$login."'");

I would do this as such:

WHERE username = '$login' ");
_________________
Central Coast, NSW, Australia.

View profile  Send private message
2Code

Posts: 24
Posted: 04/13/2014, 7:24 PM

Hey Michael I appreciate your response I have tried it every way even as you suggested and still the same result the database does not get updated.
View profile  Send private message
MichaelMcDonald

Posts: 640
Posted: 04/13/2014, 11:55 PM

Try something like this ....


$SQL = "UPDATE USERS set online ='1' " . "," . "time = NOW() " . "WHERE username = '$login' ";
$db->query($SQL);

_________________
Central Coast, NSW, Australia.

View profile  Send private message
2Code

Posts: 24
Posted: 04/15/2014, 1:27 AM

Nope its still not setting the value to 1 in the user_online field I have ccs5.1
View profile  Send private message
MichaelMcDonald

Posts: 640
Posted: 04/15/2014, 3:22 AM

You are attempting to update with username as a session variable before the value for the session variable is even set.

Read the PHP files here and come up to speed on query logic ...

php.net
_________________
Central Coast, NSW, Australia.

View profile  Send private message

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.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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