/    Sign up×
Community /Pin to ProfileBookmark

Please help learner with simple log function

I have added a log function to Access_user Class ver. 1.99 which logs user’s user_ip_address, user’s log-in_name and date/time, which works when called from the redirected web-page (main page) which is called by the log-in function after it has executed. But calling it from here logs every time a user visits the main page, and if I call it from the log-in page it doesn’t record the user because the log function fires before log-in function.

Ive tried to add the log function to the log-in function inside the class with limited success, I cant seem to get $user variable statement to record the user in the log table. It works $user = $_SESSION[‘user’] from outside the class but I can’t get the $user variable to point correct class variable to make it work from within the class.

Any suggestions or advice will be gratefully accepted as I am learner learning PHP and loving it!

Here is my log function;

[<?PHP]
function LogEvent($event) {
$log_datetime = date(“Y-m-d H:i:s”);
$log_user = $_SESSION[‘user’];
$log_ipaddress = $_
SERVER[‘REMOTE_ADDR’];
$log_info = sprintf(“INSERT INTO amsa_logs ( logs_DateTime, logs_Host, logs_User, logs_Event) VALUES (‘$log_datetime’,’$log_ipaddress’,’$log_user’,’$event’)”,
$this->table_name);
$this->ins_string($log_datetime);
$this->ins_string($log_ipaddress);
$this->ins_string($log_user);
$this->ins_string($event);
mysql_query($log_info); //cox///
}
[?>]

The class I’ve butchered ?
[ATTACH]15055[/ATTACH]

[canned-message]attachments-removed-during-migration[/canned-message]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@coxy40authorSep 30.2012 — problem solved, wasn't the function, it was where i was calling it from, when call it from the user(goto_page) function its works fine.
×

Success!

Help @coxy40 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...