Using sql values as email addresses
Posted: Fri Feb 11, 2011 5:39 pm
Im having a little trouble with the script below. I get my three sql values returned fine, without a problem.
The problem is that Im not sending any emails with it.
Wether this is a problem with my syntax, headers, code ??? i dont know.
Please go easy on my scripts, im a learning newbie.
The problem is that Im not sending any emails with it.
Wether this is a problem with my syntax, headers, code ??? i dont know.
Please go easy on my scripts, im a learning newbie.
Code: Select all
<html><body>
<?php
mysql_connect("***","***","***");
mysql_select_db("***") or die("Unable to select database");
$code = $_GET['postcode'];
$message = $_GET['message'];
$shortcode = substr($code,0,2);
$subject = "subject here";
$result = mysql_query("SELECT email FROM treesurgeons WHERE postcode like '%" . $shortcode . "%' ORDER BY companyName LIMIT 3")
or die(mysql_error());
echo "<h2>Business Names:</h2>";
while($row = mysql_fetch_assoc($result))
{$message .= "\r\n". $row['email'] ;}
{$value = $row['email'].',';}
rtrim($row, ',');
$i = 0;
{$i++; switch($i)
{case 0:$value1 = $row['email']; break;
case 1:$value2 =$row['email']; break;
case 2:$value3 =$row['email']; break; }}
$to = "$value1, $value2, $value3";
echo nl2br ($message);
$headers = 'From: me@me.com' . "\r\n" .
'Reply-To: me@me.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail( "$to", "$subject","$message", "$headers");
echo "<br>" . "Thank you for using our mail form.";
?></body></html>