I have a very basic form to email users on my site. What I would like to do is be able to select a username from a select box and email that user.
My html form is this
[code]
<table align=”center” width=”80%”><tr><td>
<b>Send Email</b><br><br>
<form action=”action.php” method=”post”>
E-mail:<br><select name=”email”>
<OPTION VALUE=””>Select User
<OPTION VALUE=”User Email Goes Here”>Username
</SELECT> <br>
Message:<br>
<textarea rows=”4″ name=”message” cols=”25″>
</textarea><br>
<input type=”submit” name=”submit” value=”Send Email”>
</form>
</td></tr></table>
and the php file to send the email is this
[code]
<?
$email=$_POST[’email’];
$msg=$_POST[‘message’];
$msg=stripslashes($msg);
$headers = “From: [email protected]: $emailrn”;
PRINT “Email Sent”;
mail(“$email”, “Email Subject”, “$msg”, $headers);
?>
I’d like to be able to show the username in the select box on the html form and have the users email address inserted into the php file for emailing.
The user’s info is stored in a MySql table called reguser and the email address field is Email and the user name field is Username. Is there a simple way of doing this?