Processing html/php form data and sending via email - How can I process the radio buttons and send in the email?


NEVER MIND- IT WORKS FOR SOME REASON ALL OF A SUDDEN, I FIGURED IT OUT@

I am trying to process a simple ( I think) form that builds an email with the input data from the form. I have gotten all the data to successfully process in the email except the Radio Button data.  I have tried a few solutions through the knowledge base, but none seem to exactly apply to this HTML/PHP form.  

The field is Membership Type (memtype) - the options are Gold or Platinum and I am prechecking the Gold button when I load the form.

I am hoping there is a simple solution out there.

Thanks for your help- I am just not great at processing PHP in general.
anne
<div id="theform">
	<?php
	if ( isset ($_POST['submit'])) {
 
	$problem = FALSE; // No problems so far.
	
	// Check for each value.
 
	if (empty ($_POST['applicantfirst'])) {
		$problem = TRUE;
		print '<p>Please enter your first name!</p>';
	}
	
	if (empty ($_POST['applicantlast'])) {
		$problem = TRUE;
		print '<p>Please enter your last name!</p>';
	}
	
	if (empty ($_POST['address'])) {
		$problem = TRUE;
		print '<p>Please enter your address!</p>';
	}
	
	if (empty ($_POST['city'])) {
		$problem = TRUE;
		print '<p>Please enter your city!</p>';
	}
	
	if (empty ($_POST['state'])) {
		$problem = TRUE;
		print '<p>Please enter your state!</p>';
	}
	
	if (empty ($_POST['zipcode'])) {
		$problem = TRUE;
		print '<p>Please enter your zip code!</p>';
	}
	
	if (empty ($_POST['companyname'])) {
		$problem = TRUE;
		print '<p>Please enter your Company Name!</p>';
	}
	
	if (empty ($_POST['companyaddress'])) {
		$problem = TRUE;
		print '<p>Please enter your Company address!</p>';
	}
		
	if (empty ($_POST['companycity'])) {
		$problem = TRUE;
		print '<p>Please enter your Company city!</p>';
	}
	
	if (empty ($_POST['companystate'])) {
		$problem = TRUE;
		print '<p>Please enter your Company state!</p>';
	}
	
	if (empty ($_POST['companyzipcode'])) {
		$problem = TRUE;
		print '<p>Please enter your Company zip code!</p>';
	}
 
	if (empty ($_POST['title'])) {
		$problem = TRUE;
		print '<p>Please enter your title!</p>';
	}
	
	if (empty ($_POST['phone'])) {
		$problem = TRUE;
		print '<p>Please enter your telephone number!</p>';
	}		
	
	
	if (empty ($_POST['fax'])) {
		$problem = TRUE;
		print '<p>Please enter your fax number!</p>';
	}		
		
	if (empty ($_POST['email'])) {
		$problem = TRUE;
		print '<p>Please enter your email address!</p>';
	}
	
	if (empty ($_POST['website'])) {
		$problem = TRUE;
		print '<p>Please enter your website!</p>';
	}
	
	
	if (empty ($_POST['companyrep'])) {
		$problem = TRUE;
		print '<p>Please enter your company representative!</p>';
	}
	
	if (empty ($_POST['natureofbusiness'])) {
		$problem = TRUE;
		print '<p>Please enter the nature of business!</p>';
	}
	
	if (empty ($_POST['yrsinemployment'])) {
		$problem = TRUE;
		print '<p>Please enter years in employment</p>';
	}
	
	if (empty ($_POST['noemployees'])) {
		$problem = TRUE;
		print '<p>Please enter number of employees!</p>';
	}
	
	if (empty ($_POST['referredby'])) {
		$problem = TRUE;
		print '<p>Please enter referred by!</p>';
	}
	
	if (empty ($_POST['othercolleagues'])) {
		$problem = TRUE;
		print '<p>Please enter other colleagues!</p>';
	}
 
 
 
	if (!$problem) { // If there weren't any problems...
	
 
 
	print '<h3 class = "redText">Thank you for joining the <br/>Chamber of Commerce</h3>';
		
	// Send the email.
	$body = "Thank you for joining the Chamber of Commerce! <br/>
	<br/>";
	
	
	$body .= "Membership Type: {$_POST['memtype']} <br/>";
	$body .= "Applicant First Name: {$_POST['applicantfirst']} <br/>";
	$body .= "Applicant Last Name: {$_POST['applicantlast']}<br/>";
	$body .= "Home Address: {$_POST['address']}<br/>";
	$body .= "Home City: {$_POST['city']} <br/>";
	$body .= "Home State: {$_POST['state']} <br/>";
	$body .= "Home Zip Code: {$_POST['zipcode']} <br/>";
	$body .= "Company Name: {$_POST['companyname']} <br/>";	
	$body .= "Company Address: {$_POST['companyaddress']} <br/>";	
	$body .= "Company City: {$_POST['companycity']} <br/>";	
	$body .= "Company State: {$_POST['companystate']} <br/>";	
	$body .= "Company Zip Code: {$_POST['companyzipcode']} <br/>";	
	$body .= "Title: {$_POST['title']} <br/>";	
	$body .= "Telephone No.: {$_POST['phone']} <br/>";	
	$body .= "Fax: {$_POST['fax']} <br/>";	
	$body .= "Email: {$_POST['email']}<br/>";
	$body .= "Website: {$_POST['website']}<br/>";
	$body .= "Company Representative: {$_POST['companyrep']}<br/>";
	$body .= "Nature of Business: {$_POST['natureofbusiness']} <br/>";
	$body .= "Years in Present Employment: {$_POST['yrsinemployment']} <br/>";
	$body .= "Number of Employees: {$_POST['noemployees']} <br/>";
	$body .= "Referred by: {$_POST['referredby']} <br/>";
	$body .= "Other Colleagues you would like to introduce to the Chamber of Commerce: 
	{$_POST['othercolleagues']} <br/>";
 
	$to = $_POST['email'];
	$headers['To'] = $to;	
	$headers .= "MIME-Version: 1.0\r\n";
	$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
	$headers .= "From: awpouch@gmail.com\r\n";
	$subject = "Chamber of Commerce Membership Application Complete";
	mail("anne@awpworks.com, awpouch@gmail.com", $subject, $body, $headers);
	mail($_POST['email'], $subject, $body, $headers);
 
 
	} else { // Forgot a field.
	
		print '<p>Please try again!</p>';
		
	}
 
} // End of handle form IF.
 
// Display the form.
print '<form name="form" action="membership-form-a.php" method="post"><p>';
print '
	<div id="theform">
	<label for="memtype">Gold Membership <br/>$125/yr</label><input type="radio" checked name="memtype" value="Gold Membership" id="mt1"/><br />
	<br />
	<label for="memtype">Platinum Membership<br/>$500/yr</label><input type="radio"  name="memtype" value="Platinum Membership" id="mt2"/><br />
	<br />
	<label for="firstname">Applicant First Name: </label><input type="text" name="applicantfirst" size="20" value="' . $_POST['applicantfirst'] . '" /><br />
	<br />
	<label for="lastname">Applicant Last Name: </label><input type="text" name="applicantlast" size="20" value="' . $_POST['applicantlast'] . '" /><br />
	<br />
	<label for="address">Home Address: </label><textarea name="address" rows="2" cols="25"> ' . $_POST['address'] . '</textarea><br />
	<br />
	<label for="city">Home City: </label><input type="text" name="city" size="20" value="' . $_POST['city'] . '" /><br />
	<br />
	<label for="state">Home State: </label><input type="text" name="state" size="20" value="' . $_POST['state'] . '" /><br />
	<br />
	<label for="zipcode">Home Zip Code: </label><input type="text" name="zipcode" size="20" value="' . $_POST['zipcode'] . '" /><br />
	<br />
	<label for="companyname">Company Name: </label><input type="text" name="companyname" size="20" value="' . $_POST['companyname'] . '" /><br />
	<br />
	<label for="companyaddress">Company Address: </label><textarea name="companyaddress" rows="2" cols="25"> ' . $_POST['companyaddress'] . '</textarea><br />
	<br />
	<label for="companycity">Company City: </label><input type="text" name="companycity" size="20" value="' . $_POST['companycity'] . '" /><br />
	<br />
	<label for="companystate">Company State: </label><input type="text" name="companystate" size="20" value="' . $_POST['companystate'] . '" /><br />
	<br />
	<label for="companyzipcode">Company Zip Code: </label><input type="text" name="companyzipcode" size="20" value="' . $_POST['companyzipcode'] . '" /><br />
	<br />
	<label for="title">Title: </label><input type="text" name="title" size="20" value="' . $_POST['title'] . '" /><br />
	<br />
	<label for="phone">Telephone No.: </label><input type="text" name="phone" size="20" value="' . $_POST['phone'] . '" /><br />
	<br />
	<label for="fax">Fax: </label><input type="text" name="fax" size="20" value="' . $_POST['fax'] . '" /><br />
	<br />
	<label for="email">Email Address: </label><input type="text" name="email" size="20" value="' . $_POST['email'] . '" /><br />
	<br />
	<label for="website">Website: </label><input type="text" name="website" size="20" value="' . $_POST['website'] . '" /><br />
	<br />
	<label for="companyrep">Company Representative: </label><input type="text" name="companyrep" size="20" value="' . $_POST['companyrep'] . '" /><br />
	<br />
 
	<label for="natureofbusiness">Nature of Business: </label><input type="text" name="natureofbusiness" size="20" value="' . $_POST['natureofbusiness'] . '" />
	<br />
	<br />
	<label for="yrsinemployment">Years in Present Employment: </label><input type="text" name="yrsinemployment" size="20" value="' . $_POST['yrsinemployment'] . '" />
	<br />
	<br />
	<label for="noemployees">Number of Employees: </label><input type="text" name="noemployees" size="20" value="' . $_POST['noemployees'] . '" /><br />
	<br />
	<label for="referredby">Referred by: </label><input type="text" name="referredby" size="20" value="' . $_POST['referredby'] . '" /><br />
	<br />
	<label for="occupation">Occupation: </label><input type="text" name="occupation" size="20" value="' . $_POST['occupation'] . '" /><br />
	<br />
	<label for="othercolleagues">Other Collegues you would <br/>like to introduce to the<br/> Chamber of Commerce: </label><textarea name="othercolleagues" 		rows="2" cols="25"> ' . $_POST['othercolleagues'] . '</textarea><br />
	<br/>
</p>';
 
print '<p class="submit"><input type="submit" name="submit" value="Submit"/></p>';
 
print '</div>';
 
print '</form>';	
print '</div>';
?>
</div>

Open in new window

apouchAsked:
Who is Participating?
 
apouchAuthor Commented:
I found my error in my code, wasn't calling the correct program for the form.
0
 
Ray PaseurCommented:
This is a great book for building your PHP and MySQL skills:

http://www.sitepoint.com/books/phpmysql1/

Best regards, ~Ray
0
 
apouchAuthor Commented:
Thanks Ray!  Looks good.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.