This topic is locked

Email event question

5/2/2007 4:30:24 PM
PHPRunner General questions
R
rcurtin author

I was just curious can you have the username of the current person logged in come up in the subject or the body of an email sent from an event?
I could not get the factory code to work for emailing so here is the code I added in there for the event.
function AfterAdd()

{
$to = 'email@email.com';

$subject = 'User Database';

$message = 'There has been been an entry added to the User Table';

$headers = 'From: Database Alert' . "\r\n" .

'Reply-To: email@email.com' . "\r\n" .

'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);

}
I would like to incorporate the {$username} tag so as to make the message "There has been an entry added to the User table by (fill in current logged in user here)"
I just would like to know who is doing what and when to the database being used in a corporate enviroment ~
p.s. I am only vaugly familiar with actual PHP writing hense why I purchased PHPRunner hehe
EDIT: oh yeah another quick thing if I have a table that allows for blank entries for 3 different inputs (all straight text first/last names) is there a way to make the count command NOT count the empty spaces?
example I have first/last (expired CC), first/last (invalid CC), and first/last (inv. zip code) for orders made. There is a TON more invalid CC numbers than invalid zip codes but when I use the count command all 3 fields get same number since it counts all the blanks.... is there a way to count only the entries with actual values?

L
larsonsc 5/2/2007

I would guess you could just add another $message .= line and call the SESSION for user ID. I've never done this mind you, but it's what I would start with.

R
rcurtin author 5/2/2007

I tried adding the {$username} in the message text but the code only comes through. I am not sure what you mean by calling the session for the user ID?
refer to first post I know BASIC if that for actual PHP stuff hehe

L
larsonsc 5/2/2007

Sorry, I see that in my response I skipped the word variable after session. Try the following and see if it works for you:
$message .= $_SESSION["UserID"]

jwoker 5/4/2007

That will get you there id number and you will probably need something like this to get their name:

$strSQLselect = "select name from users where id = '".$_SESSION["UserID"]."'";

$rs = db_query($strSQLselect,$conn);

$data=db_fetch_array($rs);

$username = $data["name"];