PHP Sendgrid

I am using a mail service called SendGrid.  I am running into a few problems evn after following the documentation to a "T".
$email = new SendGrid\Email();

$fname = $_POST['item_options[first_name]'];
$lname = $_POST['item_options[last_name]'];

$fullname = $fname. '' . $lname;

if(isset($_POST['item_options[gender]'])) {
	$gender = $_POST['item_options[gender]'];
} else {
	$gender= '';	
}

if(isset($_POST['item_options[marital_status]'])) {
	$marital_status = $_POST['item_options[marital_status]'];
} else {
	$marital_status = '';	
}

if(isset($_POST['minors'])) {
	$minors = $_POST['minors'];
} else {
	$minors = '';	
}
$professional_cyclist = $_POST['professional_cyclist'];
$triathlete = $_POST['triathlete'];

if(isset($_POST['association_membership'])) {
		$association_membership = $_POST['association_membership'];
	} else {
		$association_membership = '';	
	}
	
$product_deductible = $_POST['product_deductible'];

if(isset($_POST['product_liability'])) {
	$product_liability = $_POST['product_liability'];	
} else {
	$product_liability = '';	
}
if(isset($_POST['product_medical'])) {
		$product_medical = $_POST['product_medical'];
	} else {
		$product_medical = '';	
	}
if(isset($_POST['product_contact'])) {
	$product_contact = $_POST['product_contact'];	
} else {
	$product_contact = '';	
}


$type_bicycle = $_POST['type_bicycle'];


if(isset($_POST['year_built'])) {
	$year_built = $_POST['year_built'];
} else {
	$year_built = '';	
}

if(isset($_POST['manufacturer'])) {
	$model = $_POST['model'];
	} else {
		$model = '';
		}

if(isset($_POST['serial_number'])) {
	$serial_number = $_POST['serial_number'];
	} else {
		$serial_number = '';
	}

$bicycle_material = $_POST['bicycle_material'];
$usage = $_POST['usage'];

if(isset($_POST['purchase_date'])) {
	$purchase_date = $_POST['purchase_date'];
} else {
	$purchase_date = '';
}	
if(isset($_POST['purchase_price'])) {
	$purchase_price = $_POST['purchase_price'];
} else {
	$purchase_price = '';	
}

$used = $_POST['used'];


if(isset($_POST['accessories_value'])) {
	$accessories_value = $_POST['accessories_value'];
} else {
	$accessories_value = '';	
}

if(isset($_POST['attached_accessories'])) {
	$attached_accessories = $_POST['attached_accessories'];
} else {
	$attached_accessories = '';	
}

$bicycle_location = $_POST['bicycle_location'];
$location_address = $_POST['location_address'];
$location_city = $_POST['location_city'];
$location_state = $_POST['location_state'];
$location_zip = $_POST['location_zip'];
$contact_email = $_POST['email_address'];


$email
    ->addTo('robert@baycreative.com')
    ->addTo('rgranlund@rockintuit.com')
    ->setFrom('sales@spokeinsurance.com')
    ->setSubject('Spoke Sales Lead')
	->setHtml('<b>Name::</b> '.$fullname)
	->setHtml('<b>Email:: </b> '.$contact_email)
	->setHtml('<b>Gender:: </b> '.$gender)
	->setHtml('<b>Marital Status:: </b> '.$marital_status) 
	->setHtml('<b>Minors:: </b> '.$minors)	
	->setHtml('<b>Professional Cyclist:: </b> '.$professional_cyclist) 
	->setHtml('<b>Triathlete:: </b> '.$triathlete)
	->setHtml('<b>Association Membership:: </b> '.$association_membership)
	->setHtml('<b>Deductible:: </b> '.$product_deductible)
	->setHtml('<b>Liability:: </b> '.$product_liability) 
	->setHtml('<b>Medical:: </b> '.$product_medical)
	->setHtml('<b>Contact:: </b> '.$product_contact) 
	->setHtml('<b>Type of Bicycle:: </b> '.$type_bicycle)
	->setHtml('<b>Year Built:: </b> '.$year_built)
	->setHtml('<b>Model:: </b> '.$model)
	->setHtml('<b>Serial Number:: </b> '.$serial_number)
	->setHtml('<b>Bicycle Material:: </b> '.$bicycle_material)
	->setHtml('<b>Usage:: </b> '.$usage)
	->setHtml('<b>Purchase Date:: </b> '.$purchase_date)
	->setHtml('<b>Purchase Price:: </b> '.$purchase_price)	
	->setHtml('<b>New or Used:: </b> '.$used) 
	->setHtml('<b>Accessories Value:: </b> '.$accessories_value) 
	->setHtml('<b>Attached Accessories:: </b> '.$attached_accessories)
	->setHtml('<b>Bicycle Location:: </b> '.$bicycle_location) 
	->setHtml('<b>Location Address:: </b> '.$location_address) 
	->setHtml('<b>Location City:: </b> '.$location_city) 
	->setHtml('<b>Location State:: </b> '.$location_state)
	->setHtml('<b>Location Zip:: </b> '.$location_zip);


$sendgrid->send($email);

Open in new window


1. When It sends an email it only sends the last line: ->setHtml('<b>Location Zip:: </b> '.$location_zip);
2. Are these two lines formatted correctly?
$fname = $_POST['item_options[first_name]'];
$lname = $_POST['item_options[last_name]'];
LVL 8
rgranlundAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gr8gonzoConsultantCommented:
1. Try combining all the lines of content into a single variable and then pass that variable to setHtml.
2. Probably not. If you have a multi-dimensional array, try:
$fname = $_POST['item_options']['first_name'];

If that doesn't work, then try doing print_r($_POST); and posting the resulting content here.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.