I have a mail form (volunteer_send) for a site administrator to contact people associated with a certain activity (identified by the event_id variable). The variable is passed via URL from a preceeding page (as a variable called 'id'). I have spent crazy hours trying to figure out if i have a syntax error or something because I cannot get the variable to pass. If I hard code the id in the select statement, then it works fine.
Also, I changed the syntax of the select statement to event_id = event_id and it emailed everyone in the list while I was testing. woops.
any insight would be great.
Code: Select all
<?php
include('dbconfig.php');
// Make a MySQL Connection
mysql_connect("localhost", "$user", "$password") or die(mysql_error());
mysql_select_db("$database") or die(mysql_error());
$adminmail="event@xxxxxxxxx.com";
// Pass the event id variable
$event_id=$_GET['id'];
if(isset($_POST['submit']))
{
$subject=$_POST['subject'];
$nletter=$_POST['nletter'];
if(strlen($subject)<1)
{
print "You did not enter a subject.";
}
else if(strlen($nletter)<1)
{
print "You did not enter a message.";
}
else
{
$nletter=$_POST['nletter'];
$subject=$_POST['subject'];
$nletter=stripslashes($nletter);
$subject=stripslashes($subject);
$lists=$_POST['lists'];
$nletter=str_replace("rn","<br>",$nletter);
//the block above formats the letter so it will send correctly.
$getlist="SELECT * from volunteer WHERE event_id= '$event_id' "; //select e-mails in ABC order
$getlist2=mysql_query($getlist) or die("Could not get list");
while($getlist3=mysql_fetch_array($getlist2))
{
$headers = "From: $adminmail \r\n"; //unlock adminmail above and insert $adminmail for email address
$headers.= "Content-Type: text/html; charset=ISO-8859-1 "; //send HTML enabled mail
$headers .= "MIME-Version: 1.0 ";
mail("$getlist3[email]","$subject","$nletter",$headers);
}
print "Your Message Has Been Sent.";
}
}
else
{
print "<form action='volunteer_send.php' method='post'>";
print "Subject:<br>";
print "<input type='text' name='subject' size='20'><br>";
print "Message:<br>";
print "<textarea name='nletter' cols='50' rows='6'></textarea><br>";
print "<input type='submit' name='submit' value='submit'></form>";
}
?>