Link to home
Start Free TrialLog in
Avatar of natsully
natsullyFlag for United States of America

asked on

Passing Multiple Variables through form

I have this form that is partially working but I need a few more elements to be working.

I have added fields for a Name, Email Address, and Site (all of which need to be required).  I'm new to php and need help passing these variables through to the email that is received when submitted.

Currently I get the email, But I would like the user to choose a person to receive a CC of the email.
The box is there but no coding behind it.

PLEASE HELP.

I also have values in the form added that haven't been added to the PHP yet.
I need help with that but can post that in another question if I need to.
<?php
if( !empty($_POST['action']) )
{
	header("Content-type: text/plain");
	$submittedData="";
	foreach($_POST['StandardSupplies'] as $value)
	{
		$k=$value."_quantity";
		if(!empty($_POST[$k]))
			$submittedData .= "\n".str_replace("_"," ",$value) . ": " . $_POST[$k];
	}
	$submittedData .="\nNo Worries Campaign";
	$submittedData .="\n\tQuantity: " . $_POST['NWC_quantity'];
	$nwc=array('Flyers','Posters','Banners','Post_Cards');
	foreach($nwc as $chk)
	{
		if( !empty($_POST[$chk]) )
		{
			$submittedData .= "\n\t" . $chk.":";
			foreach($_POST[$chk] as $value)
			{
				$submittedData .= "\n\t\t".str_replace("_"," ",$value);
			}
		}
	}
	if(!empty($submittedData))
	{
		mail("natalie.teinert@clvusa.com","Order details",$submittedData);
		echo "\n\nThank you!";
	}
	exit;
}
?>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 
<html>
<head>
<title></title>
<style type="text/css">
<!--
.row1{float:left;width:25%;}
.row2{float:left;width:20%;}
.col1{float:left;width:49%;}
fieldset{padding:5px;}
fieldset div select{display:block;}
legend{font-weight:bold;background-color:white;}
fieldset fieldset{border:0px; border-top:1px dashed black;margin-top:1em;}
-->
</style>
 
</head>
<body>
<form id="form1" name="form1" method="post" action="orderform_thanks.php">
  <label><strong>Name:</strong></label>
  <input name="Name" type="text" id="Name" size="27">
  <br><br>
  <label><strong>Email:</strong></label>
  <input name="Email" type="text" id="Email" size="27">
  <br><br>
<label><strong>Site:</strong></label>
<input name="Site" type="text" id="Site" size="29">
<br>
<br>
<label>Regional Manager
<select name="regional_manager" id="regional_manager">
  <option selected>-</option>
  <option>Person A</option>
  <option>Person B</option>
  <option>Person C</option>
  <option>Person D</option>
  <option>Person E</option>
  <option>Person F</option>
</select>
</label>
<br>
<br>
  <fieldset><legend>Standard Supplies</legend>
		<div class="row1"><input type="checkbox" name="StandardSupplies[]" value="RateSheet" />Ratesheet <select name="RateSheet_quantity"><option value="0" selected>-</option><option value="500">500</option><option value="1000">1000</option><option value="1500">1500</option><option value="2000">2000</option>
	      <option value="2500">2500</option>
	      <option value="3000">3000</option>
	      <option value="3500">3500</option>
	      <option value="4000">4000</option>
	      <option value="4500">4500</option>
	      <option value="5000">5000</option>
		</select></div>
		<div class="row1"><input type="checkbox" name="StandardSupplies[]" value="Table_Drape" />Table Drape <select name="Table_Drape_quantity"><option value="0" selected>-</option>
		    <option value="1 - 6 ft.">1 - 6 ft.</option>
		    <option value="2 - 6 ft.">2 - 6 ft.</option>
		    <option value="3 - 6 ft.">3 - 6 ft.</option>
		    <option value="1 - 8 ft.">1 - 8 ft.</option>
		    <option value="2 - 8 ft.">2 - 8 ft.</option>
		    <option value="3 - 8 ft.">3 - 8 ft.</option>
		</select></div>
		<div class="row1"><input type="checkbox" name="StandardSupplies[]" value="Banner_Stands" />Banner Stands <select name="Banner_Stands_quantity"><option value="0" selected>-</option>
		    <option value="1">1</option>
		    <option value="2">2</option>
		    <option value="3">3</option>
		</select></div>
  <div><input type="checkbox" name="StandardSupplies[]" value="T_Shirts" />T-Shirts <select name="T_Shirts_quantity"><option value="0" selected>-</option><option value="500">500</option><option value="1000">1000</option><option value="1500">1500</option><option value="2000">2000</option>
      <option value="2500">2500</option>
      <option value="3000">3000</option>
      <option value="3500">3500</option>
      <option value="4000">4000</option>
      <option value="4500">4500</option>
      <option value="5000">5000</option>
  </select></div>
  </fieldset>
<br>
   <fieldset><legend>No Worries - Flyers</legend>
		<div class="row1"><input type="checkbox" name="NoWorriesFlyers[]" value="ClassFlyer" />Class In Ten Minutes? <select name="ClassFlyer_quantity"><option value="0" selected>-</option><option value="500">500</option><option value="1000">1000</option><option value="1500">1500</option><option value="2000">2000</option>
		    <option value="2500">2500</option>
		    <option value="3000">3000</option>
		    <option value="3500">3500</option>
		    <option value="4000">4000</option>
		    <option value="4500">4500</option>
		    <option value="5000">5000</option>
		</select></div>
		<div class="row1"><input type="checkbox" name="NoWorriesFlyers[]" value="ApartmentFlyer" />Apartment Hunting? <select name="ApartmentFlyer_quantity"><option value="0" selected>-</option><option value="500">500</option><option value="1000">1000</option><option value="1500">1500</option><option value="2000">2000</option>
		    <option value="2500">2500</option>
		    <option value="3000">3000</option>
		    <option value="3500">3500</option>
		    <option value="4000">4000</option>
		    <option value="4500">4500</option>
		    <option value="5000">5000</option>
		</select></div>
		<div class="row1"><input type="checkbox" name="NoWorriesFlyers[]" value="RoommateFlyer" />Roommate Hasn't Paid Up? <select name="RoommateFlyer_quantity"><option value="0" selected>-</option><option value="500">500</option><option value="1000">1000</option><option value="1500">1500</option><option value="2000">2000</option>
		    <option value="2500">2500</option>
		    <option value="3000">3000</option>
		    <option value="3500">3500</option>
		    <option value="4000">4000</option>
		    <option value="4500">4500</option>
		    <option value="5000">5000</option>
		</select></div>
  <div><input type="checkbox" name="NoWorriesFlyers[]" value="RentsFlyer" />'Rents Cramping Your Style? <select name="RentsFlyer_quantity"><option value="0" selected>-</option><option value="500">500</option><option value="1000">1000</option><option value="1500">1500</option><option value="2000">2000</option>
      <option value="2500">2500</option>
      <option value="3000">3000</option>
      <option value="3500">3500</option>
      <option value="4000">4000</option>
      <option value="4500">4500</option>
      <option value="5000">5000</option>
  </select></div>
  </fieldset>
<br>
   <fieldset><legend>No Worries - Posters</legend>
		<div class="row1"><input type="checkbox" name="NoWorriesPosters[]" value="ClassPoster" />Class In Ten Minutes? <select name="ClassPoster_quantity"><option value="0" selected>-</option><option value="500">500</option><option value="1000">1000</option><option value="1500">1500</option><option value="2000">2000</option>
		    <option value="2500">2500</option>
		    <option value="3000">3000</option>
		    <option value="3500">3500</option>
		    <option value="4000">4000</option>
		    <option value="4500">4500</option>
		    <option value="5000">5000</option>
		</select></div>
		<div class="row1"><input type="checkbox" name="NoWorriesPosters[]" value="ApartmentPoster" />Apartment Hunting? <select name="ApartmentPoster_quantity"><option value="0" selected>-</option><option value="500">500</option><option value="1000">1000</option><option value="1500">1500</option><option value="2000">2000</option>
		    <option value="2500">2500</option>
		    <option value="3000">3000</option>
		    <option value="3500">3500</option>
		    <option value="4000">4000</option>
		    <option value="4500">4500</option>
		    <option value="5000">5000</option>
		</select></div>
		<div class="row1"><input type="checkbox" name="NoWorriesPosters[]" value="RoommatePoster" />Roommate Hasn't Paid Up? <select name="RoommatePoster_quantity"><option value="0" selected>-</option><option value="500">500</option><option value="1000">1000</option><option value="1500">1500</option><option value="2000">2000</option>
		    <option value="2500">2500</option>
		    <option value="3000">3000</option>
		    <option value="3500">3500</option>
		    <option value="4000">4000</option>
		    <option value="4500">4500</option>
		    <option value="5000">5000</option>
		</select></div>
  <div><input type="checkbox" name="NoWorriesPosters[]" value="RentsPoster" />'Rents Cramping Your Style? <select name="RentsPoster_quantity"><option value="0" selected>-</option><option value="500">500</option><option value="1000">1000</option><option value="1500">1500</option><option value="2000">2000</option>
      <option value="2500">2500</option>
      <option value="3000">3000</option>
      <option value="3500">3500</option>
      <option value="4000">4000</option>
      <option value="4500">4500</option>
      <option value="5000">5000</option>
  </select></div>
  </fieldset>
<br>
   <fieldset><legend>No Worries - Banners</legend>
		<div class="row1"><input type="checkbox" name="NoWorriesBanners[]" value="ClassBanner" />Class In Ten Minutes? <select name="ClassBanner_quantity"><option value="0" selected>-</option><option value="500">500</option><option value="1000">1000</option><option value="1500">1500</option><option value="2000">2000</option>
		    <option value="2500">2500</option>
		    <option value="3000">3000</option>
		    <option value="3500">3500</option>
		    <option value="4000">4000</option>
		    <option value="4500">4500</option>
		    <option value="5000">5000</option>
		</select></div>
		<div class="row1"><input type="checkbox" name="NoWorriesBanners[]" value="ApartmentBanner" />Apartment Hunting? <select name="ApartmentBanner_quantity"><option value="0" selected>-</option><option value="500">500</option><option value="1000">1000</option><option value="1500">1500</option><option value="2000">2000</option>
		    <option value="2500">2500</option>
		    <option value="3000">3000</option>
		    <option value="3500">3500</option>
		    <option value="4000">4000</option>
		    <option value="4500">4500</option>
		    <option value="5000">5000</option>
		</select></div>
		<div class="row1"><input type="checkbox" name="NoWorriesBanners[]" value="RoommateBanner" />Roommate Hasn't Paid Up? <select name="RoommateBanner_quantity"><option value="0" selected>-</option><option value="500">500</option><option value="1000">1000</option><option value="1500">1500</option><option value="2000">2000</option>
		    <option value="2500">2500</option>
		    <option value="3000">3000</option>
		    <option value="3500">3500</option>
		    <option value="4000">4000</option>
		    <option value="4500">4500</option>
		    <option value="5000">5000</option>
		</select></div>
  <div><input type="checkbox" name="NoWorriesBanners[]" value="RentsBanner" />'Rents Cramping Your Style? <select name="RentsBanner_quantity"><option value="0" selected>-</option><option value="500">500</option><option value="1000">1000</option><option value="1500">1500</option><option value="2000">2000</option>
      <option value="2500">2500</option>
      <option value="3000">3000</option>
      <option value="3500">3500</option>
      <option value="4000">4000</option>
      <option value="4500">4500</option>
      <option value="5000">5000</option>
  </select></div>
  </fieldset>
<br>
   <fieldset><legend>No Worries - Postcards</legend>
		<div class="row2"><input type="checkbox" name="NoWorriesPostcards[]" value="ClassPostcard" />Class In Ten Minutes? <select name="ClassPostcard_quantity"><option value="0" selected>-</option><option value="500">500</option><option value="1000">1000</option><option value="1500">1500</option><option value="2000">2000</option>
		    <option value="2500">2500</option>
		    <option value="3000">3000</option>
		    <option value="3500">3500</option>
		    <option value="4000">4000</option>
		    <option value="4500">4500</option>
		    <option value="5000">5000</option>
		</select></div>
		<div class="row2"><input type="checkbox" name="NoWorriesPostcards[]" value="ApartmentPostcard" />Apartment Hunting? <select name="ApartmentPostcard_quantity"><option value="0" selected>-</option><option value="500">500</option><option value="1000">1000</option><option value="1500">1500</option><option value="2000">2000</option>
		    <option value="2500">2500</option>
		    <option value="3000">3000</option>
		    <option value="3500">3500</option>
		    <option value="4000">4000</option>
		    <option value="4500">4500</option>
		    <option value="5000">5000</option>
		</select></div>
		<div class="row2"><input type="checkbox" name="NoWorriesPostcards[]" value="RoommatePostcard" />Roommate Hasn't Paid Up? <select name="RoommatePostcard_quantity"><option value="0" selected>-</option><option value="500">500</option><option value="1000">1000</option><option value="1500">1500</option><option value="2000">2000</option>
		    <option value="2500">2500</option>
		    <option value="3000">3000</option>
		    <option value="3500">3500</option>
		    <option value="4000">4000</option>
		    <option value="4500">4500</option>
		    <option value="5000">5000</option>
		</select></div>
  <div class="row2"><input type="checkbox" name="NoWorriesPostcards[]" value="RentsPostcard" />'Rents Cramping Your Style? <select name="RentsBanner_quantity"><option value="0" selected>-</option><option value="500">500</option><option value="1000">1000</option><option value="1500">1500</option><option value="2000">2000</option>
      <option value="2500">2500</option>
      <option value="3000">3000</option>
      <option value="3500">3500</option>
      <option value="4000">4000</option>
      <option value="4500">4500</option>
      <option value="5000">5000</option>
  </select></div>
  <div><input type="checkbox" name="NoWorriesPostcards[]" value="ForeignPostcard" />Foreign City?<select name="ForeignPostcard_quantity"><option value="0" selected>-</option><option value="500">500</option><option value="1000">1000</option><option value="1500">1500</option><option value="2000">2000</option>
      <option value="2500">2500</option>
      <option value="3000">3000</option>
      <option value="3500">3500</option>
      <option value="4000">4000</option>
      <option value="4500">4500</option>
      <option value="5000">5000</option>
  </select></div>
  </fieldset>
<br>
<br>
<input type="submit" name="Submit" id="Submit" value="Submit">
</label>
</form>
</body>
</html>

Open in new window

SOLUTION
Avatar of DerkArts
DerkArts
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of natsully

ASKER

I have to be honest and say I don't know if I'm advanced enough to do the php mailer stuff.
yessirnosir, how would I incorporate that text with my current coding?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yessirnosir
yessirnosir

Hi, sorry I didn't get back to this sooner... looks like you have things under control.

Some free advice... I'm no expert in form-security, but I've learned the hard way that my online forms that generate e-mail eventually get attacked by hackers or hacker-bots.  Sometimes its just pranksters sending stupid jokes, but for me the wake-up call was when my e-mail inbox suddenly filled with thousands of messages generated by some robot that just kept pressing "submit" on my form over and over .   So since then I've learned enough about form security to at least prevent major disasters... I use a basic "captcha" functionality and IP address tracking on my forms.  Have included below some very simple code for IP tracking.  The IP address is captured and included as part of the e-mail message.  Plus I usually display it on screen as a bit of a deterrent, at least for random pranksters who may think twice about what they are doing if they know you are tracking them.  Captcha is a little more work, but if you Google it there is a ton of info out there about how to do it.

<?php $ip = "$_SERVER[REMOTE_ADDR]"; ?>
<form action="yourphp.php" method="post">
<input name="ipaddress" type="hidden" value="<?php echo $ip; ?>" />
Your IP Address is: <?php echo $ip; ?>
</form>	

Open in new window

yessirnosir,
I appreciate your suggestions!
I do have some questions.
What I'm working for is designed strictly for internal matters. It won't be a heavy traffic site but is just designed for streamlining some product requests.
The link of the site would be placed as a link on a password protected site.

Are hackers only looking for forms on public websites or can they find websites like the one I am building too?
If your form is password protected, then you can pretty much ignore everything I said!  Unless your fellow employees are a devious bunch ;-)
Okay, just wanted to make sure!
I'm new to this so I appreciate the suggestions.

Can hackers search for open forms or do they have to come across the form manually and then spam through it? (*for future reference)
I imagine it is automated, but I don't really know.  The time I really got nailed it was with a form that had been working with no security at all for several months before it got hit, so why it suddenly attracted attention, I don't know.   digressing a bit... I had another eye-opening experience a couple of years ago when I wanted to transfer some big files from my computer across the internet to my brother.  So I temporarily set up an FTP server on my home PC, with no security.  Within 12 hours (!) someone from China had discovered my open FTP, and managed to crash my Windows installation with some kind of folder-depth overflow, i.e it created nested folders inside folders repeatedly on my hard drive until Windows crashed.  So clearly there are programs probing for weaknesses all the time.  I also had my FTP userid and password for one of my sites "sniffed" just a few months ago, again by someone with China-based IP address who uploaded hundreds of pages to my website containing nothing but popups and links for spyware and viruses.  I didn't even know it had happened for several weeks, when I checked my web traffic stats and found the highest traffic was for a page that I'd never heard of!   And of course you probably know e-mail addresses on web pages get harvested for spam lists by other robots.  So best to obfuscate any e-mail address that you need to put on a site, to at least slow down the robots a bit.