What im attempting to do is pull email address from a database already built, i need to be able to select the email address depending on the date they are given.
Then i need to be able to Implode the list of email address so i can send out multiple emails to multiple Clients at one time. This is what i have so far.
*************** ***Form Application**** ************
<select name="emailto" size="15" multiple id="emailto" style="color: #000000; font-size: 8pt; font-family: Verdana" tabindex="">
<?php
$users_sql = "SELECT * FROM ******* WHERE site_tag = '*****' AND date_received BETWEEN '" . $_POST["startDate"] . "' AND '" . $_POST["endDate"] . "'";
$users_result = @mysql_query($u sers_sql);
while($users = @mysql_fetch_ar ray($users_resu lt))
{
echo "<option";
echo">" . $users["email"] ;
echo",</option>\n";
}
?>
</select>
*************** ***********
*************** ***********php code*********** **********
if($_POST['email_now'])
{
$to = $_POST['emailto'];
$from = "************** *";
$subject = "************** *****";
$headers .= ''************* **".$eol;
$headers .= '************** '.$eol;
$headers .= 'Return-Path: '.$eol; // these two to set reply address
$headers .= "Message-ID: <".$subject.">" .$eol;
//$headers .= "Message-ID: <".$now." TheSystem@".$_S ERVER['SERVER_NAME'].">".$eol;
$headers .= "X-Mailer: PHP v".phpversion() .$eol; // These two to help avoid spam-filters
# Boundry for marking the split & Multitype Headers
$mime_boundary= md5(time());
$headers .= 'MIME-Version: 1.0'.$eol;
$headers .= 'Content-Type: text/html; charset=iso-8859-1'.$eol;
$body= $_POST['edited'];
//EOF;
$success = mail($to, $subject, $body, $headers);
if ($success)
{
$msg="";
mass_email($msg );
}
else
{
$msg=".";
mass_email($msg );
}
}
But what i need it to do is when i select or whoever i select from that form and click Email, it emails all of them. and i cant figure out for the life of me what im doing wrong.
13 5998 ak1dnar 1,584
Recognized Expert Top Contributor
Could you please tell us,what is NOT working in this script?
Please USE CODE tags in future.
Its not allowing me to send to the email address the Form brings up. Right now i have it pulling about 15 email addresses from the Database and its not sending to them only one.
ak1dnar 1,584
Recognized Expert Top Contributor
Print your emails in the list menu like this: set the name attribute in this way emailto[] -
<select name="emailto[]" multiple="MULTIPLE" id="emailto[]">
-
<option value="1@domain.com">1@domain.com</option>
-
<option value="2@domain.com">2@domain.com</option>
-
<option value="3@domain.com">3@domain.com</option>
-
</select>
On server page - <?php
-
$toArray = $_POST['emailto'];
-
$explodedString = implode(",",$toArray);
-
echo $explodedString;
-
?>
Outputs: - 1@domain.com,2@domain.com,3@domain.com
Pass the $explodedString to the mail() function.
Print your emails in the list menu like this: set the name attribute in this way emailto[] -
<select name="emailto[]" multiple="MULTIPLE" id="emailto[]">
-
<option value="1@domain.com">1@domain.com</option>
-
<option value="2@domain.com">2@domain.com</option>
-
<option value="3@domain.com">3@domain.com</option>
-
</select>
On server page - <?php
-
$toArray = $_POST['emailto'];
-
$explodedString = implode(",",$toArray);
-
echo $explodedString;
-
?>
Outputs: - 1@domain.com,2@domain.com,3@domain.com
Pass the $explodedString to the mail() function.
I see where your going with that, But i need to pull the emails from the database, they arent emails i put in myself. That Form is built off email address from the mySQL Database. How do i create the array from the emails in the database?
Anyone have any idea what im trying to attempt here or what i have to do to make it work?
If you can help please by all means i would greatly appricate it. Thanks
ak1dnar 1,584
Recognized Expert Top Contributor
Oh you want to build the List menu right?
Sorry I don't have a Email Database with me, So I'm using one of my existing database. -
<?php
-
@mysql_connect("localhost","root","dba")or die(mysql_error());
-
@mysql_select_db("my_store")or die(mysql_error());
-
$result = mysql_query("SELECT p_name from products");
-
while($row=mysql_fetch_array($result)){
-
$options .= '<option value="'.$row['p_name'].'">'.$row['p_name'].'</option>';
-
}
-
?>
-
<html>
-
<body>
-
<form action="index.php" method="post">
-
<select name="emailto[]" multiple="MULTIPLE" id="emailto[]">
-
<?php echo $options ?>
-
</select>
-
<input type="submit" name="Submit" value="Submit" />
-
</form>
-
</body>
-
</html>
-
Ok, so that builds the menu, how do i take whats in that menu and email all of the clients that are brought up in that menu?
I need to be able to Click iether 1 or 20 of those items in that menu and be able to email the. Any ideas?
[PHP]
<?php
if($_POST['email_now'])
{
$to = $_POST['emailto'];
$from = "";
$subject = "";
$headers .= "".$eol;
$headers .= "".$eol;
$headers .= 'Return-Path: '.$eol; // these two to set reply address
$headers .= "Message-ID: <".$subject.">" .$eol;
//$headers .= "Message-ID: <".$now." TheSystem@".$_S ERVER['SERVER_NAME'].">".$eol;
$headers .= "X-Mailer: PHP v".phpversion() .$eol; // These two to help avoid spam-filters
# Boundry for marking the split & Multitype Headers
$mime_boundary= md5(time());
$headers .= 'MIME-Version: 1.0'.$eol;
$headers .= 'Content-Type: text/html; charset=iso-8859-1'.$eol;
$body= $_POST['edited'];
//EOF;
$success = mail($to, $subject, $body, $headers);
if ($success)
{
$msg="";
mass_email($msg );
}
else
{
$msg=".";
mass_email($msg );
}
}
?>
[/PHP]
I need this code to be able to read iether 1 or multiple selections for the List that is created from the database. What i need it to do is Send out an Email to any Selected Items from that list.
Can anyone see what im trying to acomplish here?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: James |
last post by:
Hi,
Have posted before, but will simplify problem here. For original post go to
http://forums.devshed.com/t80025/s.html
I have setup 2 arrays like so in my one page script:
$carers = array(
array('names' => 'Carer 01', 'hours' => 8, 'remaining' => 8),
|
by: Joel Farris |
last post by:
I've just finished reading Kevin Yank's book "Build Your Own Database Driven
Website", and I've not quite got a handle on the array variable.
Why do I need an array? Give me an example of an array in use, so that I can
understand why I'd want to store a bunch of stuff in one variable.
--
Joel Farris | Q: It reverses the logical flow of conversation.
twinkledust Designs | A: Why is top posting frowned upon?...
|
by: John Hoge |
last post by:
I'm looking to make an admin page for a web photo gallery, and I need
to make a drop down menu showing all files in a given directory that
do not have comments in a database for the given filename.
I'm curious about the most efficient way to do this. I don't want to
query the database separately for each file as this would be horribly
inefficient. I'm thinking about two arrays, one containing all
filenames in the photo directory, and one...
|
by: Rob Meade |
last post by:
Lo all,
Ok - this is what I was aiming to do, and then I thought - naahhh, that cant
be right!
query database
results to recordset
results to array using GetRows
update values in one column in array
<BOING>
|
by: EMiller |
last post by:
Hello,
I am encountering a development challenge here that seems
to be stumping me.
I am developing a C#/.NET application using an MSDE
database. There is a particular field in a table that I
need to accept a two-dimensional array of integers. When
creating the database, I chose the SQL_Variant datatype
for this column to which I will be writing the array.
| |
by: garimapuri |
last post by:
hi
ihad an array in php and iwant to insert its value in database
the coding is:
<?php
$nv_pairs = explode('&',$query_string);
$array;
list ($name, $value) = explode ('=',$nv_pairs);
$i = 0;
foreach($nv_pairs as $array) {
|
by: Haydnw |
last post by:
Hi,
I'd like to put a load of database results (several rows for 5 fields) into
a two-dimensional array. Now, this may be a really stupid question, but can
someone give me a pointer for how to do it? I can bind data to datagrids and
lists and stuff all day long, but can't seem to grasp this one. Any pointers
to a useful article / demo (or just any useful pointers!) would be much
appreciated.
Thanks,
|
by: ianenis.tiryaki |
last post by:
well i got this assignment which i dont even have a clue what i am
supposed to do. it is about reading me data from the file and load
them into a parallel array here is the question:
Step (1)
Your first task is to write a program which reads this file into two
parallel arrays in memory. One array contains the titles, and the
other array contains the authors. The arrays are 'parallel' in the
sense that the n-th element of the authors...
|
by: assgar |
last post by:
I am having problems getting the user selected form info to inserted into the mysql database.
I am also rec eving an error:
Warning: Variable passed to each() is not an array or object in
D:\web_server\webroot\common_list_process.php on line
1) I can display the contents of the $op array (see below)
2) Am I using the correct loop to unpact the array for inserting into the
database?
|
by: jmDesktop |
last post by:
In my code I cannot figure out how to retrieve multple rows from my
returned array from a class method. I have tried:
<?php
class myClass
{
private $connection;
/* Class constructor */
function myClass(){
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |