Jump to content

Select box to array


echocpt

Recommended Posts

Hi, im trying to create a emailing script where a user can choose peoples emails by a group name. At the moment im stuck as the code im running just stops at a blank page. Iv even tryed adding

error_reporting(E_ALL);
   ini_set('display_errors', '1');

error code to the page, but it still turns blank and does not send the email, could anyone look at the code and help out maybe? Thanks.

 

HTML Code.

<?php $query =  "SELECT DISTINCT `email`, `group` FROM `email`"; 
                    $result = mysql_query($query) or die(); ?>
				<?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="emailgroup">
                                  <?php 

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 } ?>

 

php code:

<?php 

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

$group = $_POST['emailgroup'];

$query = "SELECT 'email' FROM `email` WHERE group=\"" . $group . "\"";
$result = mysql_query($query) or die();
$row = mysql_fetch_object($result);

$emailusers = array (email);


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

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

Link to comment
https://forums.phpfreaks.com/topic/123661-select-box-to-array/
Share on other sites

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.