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 = '[email protected]';
$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".
 
 
 
//Send the email!
mail($to,$email_subject,$email_body);
//done. redirect to thank-you page.
header('Location: index.htm');
 
?>
Link to comment
https://forums.phpfreaks.com/topic/275301-need-help-checkbox-to-php-mail/
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" />

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.