This topic is locked

Get user email address from users table

12/9/2008 8:00:01 PM
PHPRunner General questions
U
Urnso author

I have a large form that passes from dept to dept. It keeps track of who originally entered it and also who was the last person to update a field.
The originator would like to be notified everytime the forms is updated by another user.
I have in my admin_users table with Username UserPass & UserEmail.
On the form I have added 2 new fields.
Notify and NotifyEmail
When the user checks Notify I would like it to populate the NotifyEmail automatically when saved.
There would happen to be a Session variable for the email address would there? <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=10363&image=1&table=forumtopics' class='bbc_emoticon' alt=';)' />
I already have code working to make it contact them via email. I can't seem to get the NotifyEmail field to auto populate.

U
Urnso author 12/10/2008

[codebox]global $conn,$strTableName,$xt;

global $control_NotifyEmail;

{

$sql = "select UserEmail from rhusers where UserName='".$_SESSION["UserID"]."'";

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

$data = db_fetch_array($rs);

$control_NotifyEmail["params"]["value"] = $data["NotifyEmail"];

}

[/codebox]
NotifyEmail is a field on the add page. I am using this code on event Add Page:Before Display. It will not populate the email address of the user entering the form.
I think it has to do with global $control_NotifyEmail; But I am unsure what to put there.
Can someone help?

U
Urnso author 12/10/2008

Ok I tried this in the Add Page Before Process. It doesn't work either. What am I missing. It seems like it should work!!
[codebox]//** Custom code ****

// put your custom code here

global $conn,$strTableName,$xt;

{

$sql = "select UserEmail from rhusers where UserName='".$_SESSION["UserID"]."'";

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

$data = db_fetch_array($rs);

$_SESSION["NotifyEmail"] = $data["NotifyEmail"];

}[/codebox]

J
Jane 12/11/2008

Hi,
use $readonlyfields array for readonly fields:

global $conn,$strTableName,$readonlyfields;

$sql = "select UserEmail from rhusers where UserName='".$_SESSION["UserID"]."'";

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

$data = db_fetch_array($rs);

$readonlyfields["NotifyEmail"] = $data["UserEmail"];