Solved

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

Posted on 2009-04-05
3
246 Views
Last Modified: 2012-06-27

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

0
Comment
Question by:apouch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 24073282
This is a great book for building your PHP and MySQL skills:

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

Best regards, ~Ray
0
 

Author Comment

by:apouch
ID: 24075965
Thanks Ray!  Looks good.
0
 

Accepted Solution

by:
apouch earned 0 total points
ID: 24075974
I found my error in my code, wasn't calling the correct program for the form.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
The viewer will learn how to count occurrences of each item in an array.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question