Jump to content

Getting Checkbox values in email


lewerjason

Recommended Posts

Dear Members,

 

I have a form with few fields and checkbox, I want to get the check box values in email. I just get CareerFocus - Array as value in the email.

 

<td width="324" bgcolor="E9E9D4" valign="top">

<input type="checkbox" name="Question1[]" value="Marketing">

Marketing<br>

<input type="checkbox" name="Question1[]" value="Contact">

Contact<br>

<input type="checkbox" name="Question1[]" value="Intelligence">

Intelligence<br>

<input type="checkbox" name="Question1[]" value="Leadership">

Leadership<br>

<input type="checkbox" name="Question1[]" value="Product">

Development</td>

<td width="330" bgcolor="E9E9D4" valign="top">

<input type="checkbox" name="Question2[]" value="Marketing">

Devices<br>

<input type="checkbox" name="Question2[]" value="Sales">

Excellence<br>

<input type="checkbox" name="Question2[]" value="Sales & Marketing">

Adherence<br>

</td>

 

if(isset($_POST['submit']))

{

 

$CareerFocus = $_POST['Question1'];

$IndustryFocus = $_POST['Question2'];

 

}

 

if(empty($errors))

{

//send the email

$to = $your_email;

$subject="New form submission";

$from = $your_email;

$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';

 

$body = "A user $firstname submitted the contact form:\n".

"CareerFocus: $CareerFocus\n".

"IndustryFocus: $IndustryFocus\n".

 

 

//"IP: $ip\n";

 

$headers = "From: $from \r\n";

$headers .= "Reply-To: $visitor_email \r\n";

 

mail($to, $subject, $body,$headers);

 

header('Location: thank-you.html');

}

 

can anyone help with this

Link to comment
Share on other sites

This has a pretty clear explanation of working with checkboxes. Take a look at the section of code under the "Check Box Group" header: http://www.html-form-guide.com/php-form/php-form-checkbox.html

 

Basically, rather than simply doing

 

$CareerFocus = $_POST['Question1'];

you need to use an array to loop through the results.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...