RE: [PHP] email with multiple records [code included]
| From: | David Smith | Date: | Wed, 07 Mar 2001 18:57:05 +0000 |
| Subject: | RE: [PHP] email with multiple records [code included] | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-42934@lists.php.net to get a copy of this message | ||
Ok here is my code... I have another question too. How can I include in the
email a variable placed in the textarea of the form. Example: Hi your email
is $email. and it would add the variable in each email and not show $email
as plain text. Also open to any code suggestions as I am still new to php.
<?php
$connection = mysql_connect ("localhost", "root", "*****");
if ($connection == false){
echo mysql_errno().": ".mysql_error()."<BR>";
exit;
}
mysql_select_db("indywebdesign",$connection);
if ($submit) {
$sql = "SELECT * FROM email";
$result = mysql_query($sql);
while ($myrow = mysql_fetch_array($result))
{
$email = $myrow["email"];
$recipient = "$email <$email>";
$subject = "$subject";
$message = "$message";
$headers = "From: David Smith <webmaster@indywebdesign.com>\n";
mail($recipient, $subject, $message, $headers);
echo "Message Sent to $email!<BR>";
}
} else {
?>
<form method="post" action="<?php echo $PHP_SELF?>">
<INPUT TYPE="text" NAME="subject">
<TEXTAREA NAME="message" ROWS="5" COLS="30"></TEXTAREA>
<input type="Submit" name="submit" value="Edit Information">
</form>
<?php
}
?>
-----Original Message-----
From: David Smith [mailto:webmaster@indywebdesign.com]
Sent: Wednesday, March 07, 2001 1:49 PM
To: Chris Lee; php-general@lists.php.net
Subject: RE: [PHP] email with multiple records
Thanks, I should have drop a code snippet in there... My problem was the .=
-----Original Message-----
From: Chris Lee [mailto:lee@mediawaveonline.com]
Sent: Wednesday, March 07, 2001 11:39 AM
To: php-general@lists.php.net
Subject: Re: [PHP] email with multiple records
suppy a code snippit and I would have a huge advantage here, but I'll swing
in the dark on this ok.
your looping all this in a for/while/foreach loop right. your generating the
body like this ?
foreach($people as $pos => $val)
{
$email_body .= 'name is '. $people[$pos]['name'] ."\n";
$email_body .= 'email is '. $people[$pos]['email'] ."\n";
$email_body .= 'phone is '. $people[$pos]['phone'] ."\n";
mail($email_to, $email_body, $email_from);
}
right ? change it to this.
foreach($people as $pos => $val)
{
$email_body = '';
$email_body .= 'name is '. $people[$pos]['name'] ."\n";
$email_body .= 'email is '. $people[$pos]['email'] ."\n";
$email_body .= 'phone is '. $people[$pos]['phone'] ."\n";
mail($email_to, $email_body, $email_from);
}
now good change im out to lunch here, but sithout a code snippit im grabing
here. please post regarding, thank you.
--
Chris Lee
Mediawaveonline.com
ph. 250.377.1095
ph. 250.376.2690
fx. 250.554.1120
lee@mediawaveonline.com
""WreckRman2"" <wreckrman2@combatfs.com> wrote in message
news:MABBLAPKMKCPAFPFGAJKMEOPCKAA.wreckrman2@combatfs.com...
I wrote a small script like a email list only when I run it with 3 emails.
The first record gets his info, 2nd get his plus first, 3rd get his plus 2nd
and 1st. Why is it doing this?
David Smith
Number 3 record gets email with:
---------------------
Hi webmaster@indywebdesign.com,
Your email is webmaster@indywebdesign.com
Bye, WreckRman2
---
Hi wreckrman2@combatfs.com,
Your email is wreckrman2@combatfs.com
Bye, WreckRman2
----
Hi email@combatfs.com,
Your email is email@combatfs.com
Bye, WreckRman2
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net