/    Sign up×
Community /Pin to ProfileBookmark

Inserting username/email address into ‘From:’ <-Mail function

[code=php]
$query = “SELECT username FROM users WHERE user_id = ‘$_SESSION[user_id]'”;
$result = mysql_query($query) or trigger_error(“Query: $queryn<br />MySQL Error: ” . mysql_error());
$row = mysql_fetch_array($result);

//Send an email.
$message = “Problem is Picture: “.$id.”nn”;
$message.=$_POST[‘problempic’];
$sender = “$row[‘0’]”;
mail (‘[email protected]’, ‘Problem Picture’, $message, ‘From: $sender’);
echo ‘<h3>Thanks for your email. We hope to look into this problem soon.</h3>’;
mysql_close();
[/code]

How do I insert the users ‘username’ or ’email’ address into the emails ‘From’ part . I tried the above, but it just gives me $[email protected]

Any ideas would be greatly appreciated.

Thanks once more.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJan 30.2006 — Use double-quotes around a string if you want variable interpolation:
[code=php]
mail ('[email protected]', 'Problem Picture', $message, "From: $sender");
[/code]
Copy linkTweet thisAlerts:
@invisionauthorJan 30.2006 — Many thanks for your super-quick reply, that did the job!
×

Success!

Help @invision 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.16,
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,
)...