Jump to content

Recommended Posts

I've been doing a lot of research on why I keep getting the word "array" instead of what the person actually wants from the "request information" form I am creating with html/php.

 

Here's my HTML:

<p>I am Interested in:<br>

<input name="interest[]" type="checkbox" value="A Storage Shed" />A Storage Shed<br>

<input name="interest[]" type="checkbox" value="A Garage" />A Garage<br>

<input name="interest[]" type="checkbox" value="A Gazebo" />A Gazebo<br>

<input name="interest[]" type="checkbox" value="Other" />Other<br>

<input name="interest[]" type="checkbox" value="I'd like information about financing programs" />I'd like information about financing programs

</p>

 

Here's the PHP part relevant to this:

 

$nameField = $_POST['name'];

$addressField = $_POST['address'];

$cityField = $_POST['city'];

$stateField = $_POST['state'];

$zipField = $_POST['zip'];

$phoneField = $_POST['phone'];

$emailField = $_POST['email'];

$ownerField = $_POST['owner'];

$interestField = $_POST['interest'];

 

if ( isset($_POST['interest']) ) {

    $_POST['interest'] = implode(', ', $_POST['interest']); //Converts an array into a single string

  }

 

 

 

The results I am getting sent to my email under the "interest" field as marked as "array" instead of what they have actually checked.

What else do I need?

 

 

 

 

 

 

 

So like this?

That didn't work...

 

        $nameField = $_POST['name'];

$addressField = $_POST['address'];

$cityField = $_POST['city'];

$stateField = $_POST['state'];

$zipField = $_POST['zip'];

$phoneField = $_POST['phone'];

$emailField = $_POST['email'];

$ownerField = $_POST['owner'];

 

 

if ( isset($_POST['interest']) ) {

    $_POST['interest'] = implode(', ', $_POST['interest']); //Converts an array into a single string

  }

  $interestField = $_POST['interest'];

 

 

Instead of

<?php
$interestField = $_POST['interest'];

if ( isset($_POST['interest']) ) { 
     $_POST['interest'] = implode(', ', $_POST['interest']); //Converts an array into a single string
   }
?>

 

Just do

<?php
$interestField = (isset($_POST['interest']))?implode(',',$_POST['interest']):'No interests indicated';
?>

 

Ken

Yes, I know I am calling the right php file, everything else works when I use the type="text" method, but not when I use the "checkbox" method. I'm just not sure how to get the values instead of just the word "array" sent to my email. I need that data and don't know how to get it.

Here's my HTML:

 

<form  class="appnitro"  method="post" action="contactformprocess.php">
		<h2>Information Request</h2>
		<p>Thank you for your interest. Please complete the following information so that we can help serve you better.</p>

	<p>Name: <br>
	<input name= "name" class="element text medium" maxlength="255" value=""/>
	</p>

	<p>Street Address <br>
		<input name="address" class="element text medium" value="" type="text"><br>
		City <br>
		<input name="city" class="element text medium" value="" type="text"><br>
		State <br>
		<input name="state" class="element text medium" value="" type="text"><br>
		Zip Code <br>
		<input name="zip" class="element text medium" value="" type="text">
	</p>

	<p>Daytime Phone <br>

		<input name="phone" class="element text medium" type="text" maxlength="255" value=""/>
	 </p>
	<p> E-mail<br>
		<input name="email" class="element text medium" type="text" maxlength="255" value=""/> 
	</p>

<p> I am a:<br>	
<input name="owner" type="radio" value="homeowner"  checked="checked"/>Homeowner
<input name="owner" type="radio" value="Builder/Contractor"/>Builder/Contractor
</p>

<p>I am Interested in:<br>

<input name="interest[]" type="checkbox" value="A Storage Shed" />
A Storage Shed<br>
<input name="interest[]" type="checkbox" value="A Garage" />
A Garage<br>
<input name="interest[]" type="checkbox" value="A Gazebo" />
A Gazebo<br>
<input name="interest[]" type="checkbox" value="Other" />
Other<br>
<input name="interest[]" type="checkbox" value="I'd like information about financing programs" />
I'd like information about financing programs
</p>
<li id="li_6" >
	<label class="description" for="element_6">Additional Comments: </label>
	<div>
		<textarea id="element_6" name="element_6" class="element textarea medium"></textarea> 
	</div> 
	</li>

				<li class="buttons">			    
			<input type="submit" value="Submit" id="submit" class="form-submit" />
	</li>
		</ul>
	</form>	

 

 

 

and here's my PHP: (I removed my email address on purpose)

 

<?php



/* Subject and Email variables */

$emailSubject = 'Greys Info Request';
$webMaster = 'removed@email.com';


/* Gathering Data Variables */

$nameField = $_POST['name'];
$addressField = $_POST['address'];
$cityField = $_POST['city'];
$stateField = $_POST['state'];
$zipField = $_POST['zip'];
$phoneField = $_POST['phone'];
$emailField = $_POST['email'];
$ownerField = $_POST['owner'];
$interestField = (isset($_POST['interest']))?implode(',',$_POST['interest']):'No interests indicated';
$commentField = $_POST['element_6'];

$body = <<<EOD
<br><hr><br>
Name: $name <br>
Address: $address <br>
City: $city <br>
State: $state <br>
Zip Code: $zip <br>
Phone: $phone <br>
Email: $email <br>
Owner: $owner <br>
Interested in: $interest <br>
Comments: $element_6 <br>
EOD;

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body,
$headers);

/* Results  */

$theResults = <<<EOD
<html>
<head>
<title>Greys Woodworks Info Request</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-color: #f1f1f1;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #666666;
text-decoration: none;
}
-->
</style>
</head>

<div>
  <div align="left">Thank you for your interest! Your email will be answered very soon!</div>
</div>
</body>
</html>
EOD;
echo "$theResults";

?>

I've just tried this:

 

$nameField = $_POST['name'];
$addressField = $_POST['address'];
$cityField = $_POST['city'];
$stateField = $_POST['state'];
$zipField = $_POST['zip'];
$phoneField = $_POST['phone'];
$emailField = $_POST['email'];
$ownerField = $_POST['owner'];
        foreach($_POST['interest']  as  $value)  {
	$check_msg .= "Checked: $value\n";
} 
$projectField = $_POST['project'];
$contactField = $_POST['contact'];
$callField = $_POST['call'];
$timeField = $_POST['time'];
$commentField = $_POST['commment'];

 

and THAT isn't working either. Still getting "array" sent to my email.

For anyone out there in the internets, I got! I got it!!!!

 

This post helped: http://www.kirupa.com/web/php_contact_form3.htm

 

$nameField = $_POST['name'];
$addressField = $_POST['address'];
$cityField = $_POST['city'];
$stateField = $_POST['state'];
$zipField = $_POST['zip'];
$phoneField = $_POST['phone'];
$emailField = $_POST['email'];
$ownerField = $_POST['owner'];
$projectField = $_POST['project'];
$contactField = $_POST['contact'];
$callField = $_POST['call'];
$timeField = $_POST['time'];
$commentField = $_POST['commment'];

foreach($_POST['interest']  as  $value)  {
$check_msg .= "Checked: $value\n";
} 

$body = <<<EOD
<br><hr><br>
Name: $name <br>
Address: $address <br>
City: $city <br>
State: $state <br>
Zip Code: $zip <br>
Phone: $phone <br>
Email: $email <br>
Owner: $owner <br>
Interested in: $check_msg <br>
Project To Begin: $project <br>
Best Way To Contact: $contact <br>
Best Time to Call: $call
$time <br>
Comments: $comment <br>
EOD;

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.