Jump to content

Email form with checkboxes


tcwaage

Recommended Posts

I'm trying to make an email form where the addresses are stored in a database. I want to be able to display all the addresses at the top of a form and the user be able to check the people he/she wants to send a message to. I know how to display all the addresses, but how do I code it so that the scipt checks if a person is to receive the msg or not? I've attached the form code so you get sort of an idea of what it would look like.

<form id="form1" name="form1" method="post" action="">
<table width="500" border="0">
<tr>
<td><input type="checkbox" name="checkbox" value="checkbox" />
Person 1 </td>
<td>Email address </td>
</tr>
<tr>
<td> <input type="checkbox" name="checkbox2" value="checkbox" />
Person 2 </td>
<td>Email address </td>
</tr>
<tr>
<td><input type="checkbox" name="checkbox3" value="checkbox" />
Person 3 </td>
<td>Email address </td>
</tr>
<tr>
<td>Subject</td>
<td><input type="text" name="textfield" /></td>
</tr>
<tr>
<td>From</td>
<td><input type="text" name="textfield2" /></td>
</tr>
<tr>
<td>Return Email address </td>
<td><input type="text" name="textfield3" /></td>
</tr>
<tr>
<td>Message</td>
<td><textarea name="textarea" cols="30" rows="10"></textarea></td>
</tr>
<tr>
<td><div align="right">
<input type="reset" name="Submit2" value="Reset" />
</div></td>
<td><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
</form>
Link to comment
Share on other sites

try this

[code]
$getemail=mysql_query("select * from your_table");
while($getemail2=mysql_fetch_array($getemail)){
echo "<input type=checkbox name=$getemail2[your_column]> $getemail2[your_column]";
}
[/code]
that should display all the email addres in your database and set the value of the checkbox change your_table and your_column to the correct database names and you only need the one line of code and it will pull all of the email addresses
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.