Jump to content

php & mysql email form help


echocpt

Recommended Posts

Hi, once again i find myself needing some help from this fantastic site. I am trying to code an email script where the admin of my site can send emails to a group of users through the use of a form. At the moment, the admin can select a group to email through the use of a select box linked to a mysql database. He also adds the subject and message in the form and then clicks the submit button. This is where im confused. The email send script tells me the email has been sent when really nothing is being sent. Could any1 help me sort this 'small' problem  :P. Thanks.

 

html email form:

					<?php $query =  "SELECT `email`, `group` FROM `email`"; ?>
				<?php if ($_GET['email']==true) { ?>
			    <div class="msg_body">
					<p class="msg_head2">Email Users></p>
                        <form id="form5" name="form5" method="post" action="email.php">
					<table width="638" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="190" height="28" valign="top"><p><strong>Add User:</strong></p>							    </td>
						  <td width="449"><label></label></td>
						</tr>
						<tr>
							<td height="30">To:</td>
					      <td><label>
				          <select name="emailusers">
                                  <?php 
												$result = mysql_query($query) or die(); 
while($row = mysql_fetch_assoc($result))
{
    echo "<option value=''" . $row['email'] . "'>" . $row['group'] . "</option>";
}
?>
                                </select>
					      </label></td>
						</tr>
						<tr>
							<td height="30">Subject:</td>
				      <td><label>
				        <input name="subject" type="text" class="area" id="subject" />
				      </label></td>
						</tr>
						<tr>
							<td height="30">Content:</td>
					        <td><label>
					          <textarea name="emailcontent" id="emailcontent" class="box" cols="50" rows="8"></textarea>
					        </label></td>
						</tr>
						<tr>
							<td height="30"> </td>
						    <td><label></label>
						      <label></label></td>
						</tr>
						<tr>
							<td height="30"> </td>
							<td><label></label></td>
					  </tr>
						<tr>
							<td> </td>
							<td><input type="submit" name="submit" id="submit" value="Send Email" /></td>
						</tr>
						<tr>
							<td> </td>
							<td> </td>
						</tr>
						<tr>
							<td> </td>
							<td> </td>
						</tr>
						<tr>
							<td> </td>
							<td> </td>
						</tr>
					</table>
                      </form>
					<br />
					<br />
					<br />
				</div>
				<?php } ?>

 

The php email form:

<?php 
include("connection.php");
if(isset($_POST['submit'])) { 


$Name = "Woodbridge School CCF"; //senders name 
$email = "[email protected]"; //senders e-mail adress 
$message = $_POST['emailcontent'] ;
$subject = $_POST['subject'] ;
$emailusers = $_POST['emailusers'];

mail($emailusers, $subject, $message, $email); //mail command 
echo "Email Sent";
} else {
header('admin.php?email=true');
}
?> 

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/123320-php-mysql-email-form-help/
Share on other sites

Hi, thanks i looked into that and have changed, unfortunatly still no luck. Im thinking that maybe it could be something to do with pulling the email addresses from the table in the DB and then adding them. If so i would have thort it would be to do with these lines?

 

echo "<option value=''" . $row['email'] . "'>" . $row['group'] . "</option>";

in the html form

 

$emailusers = $_POST['emailusers'];

and

mail($emailusers, $subject, $message, "From: $email");

in the php code.

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.