Jump to content

Need help checkbox to php mail


Shakeel

Recommended Posts

I have 4 checkbox, 4 text field and 1 text area in my form and i need to send this information to my email

i am getting only text field and text area information not checkbox value

can anyone help me on this

 

below is the code

 

in HTML

 

<input name="checkbox" type="checkbox" id="checkbox" value="I AM INTERESTED IN BEING A DISTRIBUTOR">

<input name="checkbox" type="checkbox" id="checkbox" value="I OWN A FLEET OF COMMERCIAL VEHICLES">

<input name="checkbox" type="checkbox" id="checkbox" value="I NEED A LOCAL SUPPLIER FOR MYGREENOIL">

<input name="checkbox" type="checkbox" id="checkbox" value="I HAVE A TECHNICAL QUESTION">

<input type="text" name="name" id="name">

<input type="text" name="address" id="address">

<input type="text" name="phonenumber" id="phonenumber">

<input type="text" name="emailaddress" id="emailaddress">

<textarea name="commentsorquestion" id="commentsorquestion" cols="45" rows="5"></textarea>

 

in php

 

 

<?php
 
$name = $_POST['name'];
$address = $_POST['address'];
$phonenumber = $_POST['phonenumber'];
$emailaddress = $_POST['emailaddress'];
$InquiryFor = $_POST['inquiryfor'];
$commentsorquestion = $_POST['commentsorquestion'];
$checkbox = $_POST['checkbox'];
 
foreach($_POST['checkbox'] as $value)
{
echo 'Checked: '.$value.'
';
}
 
$email_from = 'mymail@mydomain.com';
$email_subject = "From website inquiry form";
$email_body = "$checkbox \n\nContact Person:\t$name \n\nAddress:\t$address \nPhone Number:\t$phonenumber \nEmail Address:\t$emailaddress \nComments or Questions:\t$commentsorquestion\n\n\n".
 
 
$to = "mymail@mydomain.com";
 
//Send the email!
mail($to,$email_subject,$email_body);
//done. redirect to thank-you page.
header('Location: index.htm');
 
?>
Link to comment
Share on other sites

Use this instead

 

<form action="exec.php" method="post">
<input name="checkbox[]" type="checkbox" id="checkbox" value="I AM INTERESTED IN BEING A DISTRIBUTOR">
<input name="checkbox[]" type="checkbox" id="checkbox" value="I OWN A FLEET OF COMMERCIAL VEHICLES">
<input name="checkbox[]" type="checkbox" id="checkbox" value="I NEED A LOCAL SUPPLIER FOR MYGREENOIL">
<input name="checkbox[]" type="checkbox" id="checkbox" value="I HAVE A TECHNICAL QUESTION">
<input type="submit" value="submit" />
Link to comment
Share on other sites

 

Use this instead

 

<form action="exec.php" method="post">
<input name="checkbox[]" type="checkbox" id="checkbox" value="I AM INTERESTED IN BEING A DISTRIBUTOR">
<input name="checkbox[]" type="checkbox" id="checkbox" value="I OWN A FLEET OF COMMERCIAL VEHICLES">
<input name="checkbox[]" type="checkbox" id="checkbox" value="I NEED A LOCAL SUPPLIER FOR MYGREENOIL">
<input name="checkbox[]" type="checkbox" id="checkbox" value="I HAVE A TECHNICAL QUESTION">
<input type="submit" value="submit" />

@Shakeel

This will return an array with true or false, not a single value. So maybe this is why it won't work

Link to comment
Share on other sites

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.