I wrote my first form to mail script, and it isn't working. I am stuck on troubleshooting it at this point. Can you see anything that is an obvious error? I was thinking the localhost should have an IP and not just be called "localhost," but my hosting service says to use "localhost."
<?php
$firstName=$POST['volunteer_FName'];
$lastName=$POST['volunteer_LName'];
$email=$POST['volunteer_Email'];
$telephone=$POST['volunteer_Telephone'];
$city=$POST['volunteer_City'];
$affiliation=$POST['volunteer_Affiliation'];
$website=$POST['volunteer_Website'];
$questionSkillset=$POST['volunteer_questions_skillset'];
$questionElements=$POST['volunteer_questions_elements'];
$questionDesign=$POST['volunteer_questions_design'];
//---------VALIDATION-------->
if($firstName){//----> CHECK input
}
else{
$error.="Please, go back and fill out your first name<br>\n";//----> ERROR if no input
}
if($lastName){//----> CHECK input
}
else{
$error.="Please go back and fill out your last name<br>\n";//----> ERROR if no input
}
if($email){//----> CHECK input
}
else{
$error.="Please go back and fill out your e-mail address<br>\n";//----> ERROR if no input
}
if($telephone){//----> CHECK input
}
else{
$error.="Please go back and fill out your phone number<br>\n";//----> ERROR if no input
}
if($city){//----> CHECK input
}
else{
$error.="Please go back and fill out your city<br>\n";//----> ERROR if no input
}
if($questionSkillset){//----> CHECK input
}
else{
$error.="Please go back and answer the first question<br>\n";//----> ERROR if no input
}
if($questionElements){//----> CHECK input
}
else{
$error.="Please go back and answer the second question<br>\n";//----> ERROR if no input
}
if($questionDesign){//----> CHECK input
}
else{
$error.="Please go back and answer the third question<br>\n";//----> ERROR if no input
}
//-------->ERROR FREE??
if($error==""){
echo "Thanks for you interest! We will get back to you when a project comes up that would benefit from your help.";
//----------------------------------
$mailContent="--------CONTACT--------\n"
."First Name: ".$firstName."\n"
."Last Name: ".$lastName."\n"
."E-mail: ".$email."\n"
."Phone: ".$telephone."\n"
."City: ".$city."\n"
."Affiliation: ".$affiliation."\n"
."Website: ".$website."\n\n--------QUESTIONS--------\n"
."Description of main relevant interests and specific skill-sets: ".$questionSkillset."\n"
."Three most important qualities or elements wanting to be seen in the design/implementation of the area(s) chosen: ".$questionElements."\n"
."Recommendations or references offered to the project's design/development process: ".$questionDesign."\n"
//----------------------------------
$toAddress="volunteer@greencenturyinstitute.org";
$subject="Volunteering with the Green Century Institute";
$recipientSubject="Volunteering with the Green Century Institute";
$receiptMessage = "Thank you ".$firstName." for expressing interest in volunteering!\n\n\nHere is what you submitted to us:\n\n"
."--------CONTACT--------\n"
."First Name: ".$firstName."\n"
."Last Name: ".$lastName."\n"
."E-mail: ".$email."\n"
."Phone: ".$telephone."\n"
."City: ".$city."\n"
."Affiliation: ".$affiliation."\n"
."Website: ".$website."\n\n--------QUESTIONS--------\n"
."Description of main relevant interests and specific skill-sets: ".$questionSkillset."\n"
."Three most important qualities or elements wanting to be seen in the design/implementation of the area(s) chosen: ".$questionElements."\n"
."Recommendations or references offered to the project's design/development process: ".$questionDesign."\n"
//----------------------------------
mail($email, $subject, $receiptMessage,"From:$toAddress");
//----------------------------------
mail($toAddress,$recipientSubject,$mailContent,"From:$email");
//--->echo $mailContent;
//////////////////////////////////////// CONNECT TO MYSQL DB ////////////////////
// OPEN CONNECTION --->
$connection=mysql_connect('localhost','Volunteer', 'verbumalia');
if (!$link) {
die('Could not connect: ' . mysql_error());
// EXECUTE QUERY --->
$query="INSERT INTO generalContact (
firstName,
lastName,
email,
telephone,
city,
affiliation,
website,
questionSkillset,
questionElements,
questionDesign)
VALUES(
'".$firstName."',
'".$lastName."',
'".$email."',
'".$telephone."',
'".$city."',
'".$affiliation."',
'".$website."',
'".$questionSkillset."',
'".$questionElements."',
'".$questionDesign."')";
//////----->
$result=mysql_query($query) or die("Error in query:".mysql_error());
//if ($result)
//echo mysql_affected_rows()." row inserted into the database effectively.";
mysql_close($connection);
}
else{
print "Sorry, but the form cannot be sent until the fields indicated are filled out completely - <br>\n";
print "$error<br>\n";
print "<br>\n";
print "<br>\n";
print "Please use your \"Back\" button to return to the form to correct the omissions. Thank you.<br>\n";
}
?>