im trying to send the checkbox data to both the email and to the database but for some reason it doesnt send all the of the checked items to the email or database what am i doing wrong?
here is the form:
<table width="95%" border="0" cellspacing="1" class="tablestyle" cellpadding="1" align="center">
<tr><td>Name:</td>
<td><input type="text" name="name" size="27">
</td>
</tr>
<tr>
<td>Email: </td>
<td>
<input type="text" name="email" size="27">
</td>
</tr>
<tr>
<td>Address: </td>
<td>
<input type="text" name="address" size="27">
</td>
</tr>
<tr>
<td>Home Phone: </td>
<td>
<input type="text" name="homephone" size="27">
</td>
</tr>
<tr>
<td>Alternate Phone: </td>
<td>
<input type="text" name="alternatephone" size="27">
</td>
</tr>
<tr>
<td valign="top">Please check all volunteer activities you would like to do: </td>
<td>
Website/Newsletter:<input type="checkbox" value="website_newsletter" name="activities[]"><br />
Clothing Bank:<input type="checkbox" value="clothing_bank" name="activities[]"><br />
Food Drives:<input type="checkbox" value="food_drives" name="activities[]"><br />
</td>
</tr>
<tr>
<td valign="top">Help With Special Events: </td>
<td>
Teasure Sale:<input type="checkbox" value="Teasure Sale" name="specialevents[]"><br />
Volunteer Celebation:<input type="checkbox" value="Volunteer Celebation" name="specialevents[]"><br />
Fun/Run:<input type="checkbox" value="Fun/Run" name="specialevents[]"><br />
Children's Parade:<input type="checkbox" value="Children's Parade" name="specialevents[]"><br />
</td>
</tr>
<tr>
<td valign="top">My Best Available Times are: </td>
<td>
<input type="text" name="best_time" size="27">
</td>
</tr>
<tr><td colspan="2"><input type="submit" value="Submit" class="button"></td></tr>
</table></form>
here is the commands:
<?php
$con = mysql_connect("host","user","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("t", $con);
$name=mysql_real_escape_string($_POST['name']);
$email=mysql_real_escape_string($_POST['email']);
$address=mysql_real_escape_string($_POST['address']);
$homephone=mysql_real_escape_string($_POST['homephone']);
$alternatephone=mysql_real_escape_string($_POST['alternatephone']);
$activities=mysql_real_escape_string($_POST['activities']);
$specialevents=mysql_real_escape_string($_POST['specialevents']);
$best_time=mysql_real_escape_string($_POST['best_time']);
$sql="INSERT INTO t (name,email,address,homephone,alternatephone,activities,specialevents,best_time) VALUES ('$name','$email','$address','$homephone','$alternatephone','$activities','$specialevents','$best_time')";
name and email are the respective table fields*/
if (!mysql_query($sql,$con)) {
die('Error: ' . mysql_error());
}
?>
<?php
$name = trim($_POST['name']);
$email = trim($_POST['email']);
$address = trim($_POST['address']);
$homephone = trim($_POST['homephone']);
$alternatephone = trim($_POST['alternatephone']);
$activities = trim($_POST['activities']);
$specialevents = trim($_POST['specialevents']);
$best_time = trim($_POST['best_time']);
echo" <br />";
echo" <br />";
echo" <br />";
echo "Name: ". $name . " <br />";
echo "Email: ". $email . " <br />";
echo "Address: ". $address . " <br />";
echo "Home Phone: ". $homephone . " <br />";
echo "Alternate Phone: ". $alternatephone . " <br />";
echo "Activities: ". $activities . " <br />";
echo "Special Events: ". $specialevents . " <br />";
echo "Best Time Available: ". $best_time . " <br />";
$recipient = "email";
$subject = "Volunteering form";
$message = "
'. Name: .'$name
'. Email: .' $email
'. Address: .' $address
'. Home Phone: .' $homephone
'. Alternate Phone: .' $alternatephone
'. Activites: .' $activities
'. Special Events: .' $specialevents
'. Best Time: .' $best_time
";
mail($recipient, $subject, $message);
?>
what am i doing wrong? ive been googling tutorials but it doesnt seem to work for me. ive been trying for hours and i still dont get it please help?