Hello and Thanks in advance to anyone who can help me with this noob php query.
I am trying to create a "share this record" tool in which a User can send another User a link to a record by displaying all the users in the User Table with a query inside a
SELECT tag like below.
The sender should be able to select the 'receiver' from the Drop-Down and the form will send the email message to only the person selected. The problem I am having is that it sends an email to the intended recipient, but it sends one for each user in the User table. So three users, the recipient gets three emails.
Can someone help me figure out what I'm doing wrong?
Here is an example of what I've got going on.
//variable here
$mailmsg="Hi {$row['user_fname']} {$row['user_lname']}. Email message Blah Blah";
<select name='receiver'>
<option value='0' default>Please Specify Support Person to receive email...</option>";
$result=mysql_query("select user_id, user_fname, user_lname, user_email from users");
while($row=mysql_fetch_assoc($result)){
mail("$receiver", "Record Shared with You", $mailmsg,"FROM:me@foo.org");
if($row['user_id']==$user_id){
echo"<option value='{$row['user_email']} ' selected>{$row['user_id']} {$row['user_fname']} {$row['user_lname']} ";
}
else{
echo"
<option value='{$row['user_email']}' >{$row['user_id']} {$row['user_fname']} {$row['user_lname']}
";
}
}
echo"</select>
again, thanks in advance if anyone can help me with this.
-dottomm