473,394 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to display html form selects (via checkbox) in email?

I have a simple form to collect user selections in html form. I am
pretty new to php...how can I send the user's checkbox selects to me
in an email...I am struggling with buiding an array to send this info

mail() function. Any help appreciated... Thanks very much!

tomseye

<body>
<br>
<b>Please select the information you'd like to
receive:</b>
<br>

<form method="post"
action="checked2.php"><br>
<input type="checkbox" name="foo[]"
value="Auto">Auto Insurance
<input type="checkbox" name="foo[]"
value="Life">Life Insurance
<input type="checkbox" name="foo[]"
value="Home">Home Insurance
<br><br>
<input type="submit" value="Submit">
<input type="reset" value="Clear">
</form>

<?php

echo "You have chosen to receive information on: \n\n";
// check to be sure at least one option was selected<br>

$foo = $_POST['foo'];
if (count($foo) > 0) {
// loop through the array
for ($i=0;$i<count($foo);$i++) {

// do something - this can be a SQL query, echoing data to the
browser, or whatever

echo "<li>$foo[$i]\n";

} // end "for" loop

} // endif
echo "<br>";
echo "insurance products.\n";
?>
:lol:
http://eye.cc php newsgroups
Feb 21 '06 #1
1 2966
tomseye wrote:
I have a simple form to collect user selections in html form. I am
pretty new to php...how can I send the user's checkbox selects to me
in an email...I am struggling with buiding an array to send this info

mail() function. Any help appreciated... Thanks very much!
What is your problem?

tomseye

<body>
<br>
<b>Please select the information you'd like to
receive:</b>
<br>

<form method="post"
action="checked2.php"><br>
<input type="checkbox" name="foo[]"
value="Auto">Auto Insurance
<input type="checkbox" name="foo[]"
value="Life">Life Insurance
<input type="checkbox" name="foo[]"
value="Home">Home Insurance
<br><br>
<input type="submit" value="Submit">
<input type="reset" value="Clear">
</form>
So far so good.

<?php

echo "You have chosen to receive information on: \n\n";
// check to be sure at least one option was selected<br>

$foo = $_POST['foo'];
$bodyOfEmail = "";
if (count($foo) > 0) {
Why use this if-statement?
If count($foo) is 0, you will not enter the loop.
Remove it for clarity's sake.

// loop through the array
for ($i=0;$i<count($foo);$i++) {

// do something - this can be a SQL query, echoing data to the
browser, or whatever

echo "<li>$foo[$i]\n";
$bodyOfEmail .= $foo[$i]."\n";

} // end "for" loop

} // endif
echo "<br>";
echo "insurance products.\n";
?>

Now add insurance product if you like to $bodyOfEmail, and go mailing.

Regards,
Erwin Moller
:lol:
What are you laughing about?
http://eye.cc php newsgroups


Feb 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: tomseye | last post by:
I have a simple form to collect user selections in html form. I am pretty new to php...how can I send the user's checkbox selects to me in an email...I am struggling with buiding an array to send...
2
by: Pat Scott | last post by:
I am looking for a general purpose javascript snippet that enables me to <div> or <span> HTML to make portions of the form be hidden and then appear. The form contains about 12 sections and some...
10
by: DettCom | last post by:
Hello, I would like to be able to display or hide fields based on whether a specific Yes/No radio button is selected. This is in conjunction with a posting a just made here in the same group...
3
by: Scott | last post by:
Relative newbie here, I'm looking to display the value of radio buttons and check boxes on the page before submission. So far I can do most of it. When "Hat" is checked there are to be no color...
2
by: Jake Barnes | last post by:
Imagine I've this block of HTML: <p>Alex Schein Mailing List <input type="checkbox" name="newslettersToUse" value="133156"> (<a href="mcControlPanel.php"...
12
by: Tom | last post by:
Hello, I have a database of employee data in access and I am trying to create a form with combo boxes for criteria (ex. gender, office, position, etc.) that let the user select criteria from...
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
19
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect...
3
by: Pope Pius X2 | last post by:
I have a simple php form that is submitted and the details are emailed to someone. The problem is that there is a checkbox and if the checkbox is clicked then it sends the result as "Yes". However...
1
by: arggg | last post by:
I have an external html that is a form. the Values of the form elements have <?= $results ?> type information however with file_get_contents in the main php file that then stores the contents to a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.