Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

php form to email with checkboxes

Posted on 2007-04-10
6
Medium Priority
?
291 Views
Last Modified: 2010-07-27
In a PHP form to Email I have 5 Checkboxes such as:

<input type="checkbox" name="Subject_Requested[]" id="English" value="English" />English
<input type="checkbox" name="Subject_Requested[]" id="Science" value="Science" />Science
<input type="checkbox" name="Subject_Requested[]" id="Maths"  value="Maths" /> Maths

I need to print/echo only the one that has been checked by the user:
Since the output is sent by email i included all the variables inside of the email "body" such as:

===========================================
$body ="

foreach ($Subject_Requested as $value) {
echo $value.'<br />'
};"

=============================================

But it does not seem to work. I know I should create the loop outside the "body" and then call the function, but I do not know how and I am not sure if I am right :-)

Please help..........
0
Comment
Question by:Refael
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
6 Comments
 
LVL 10

Expert Comment

by:sakuya_su
ID: 18887704
I had the following test files:

<form action="test.php" method="post">
<input type="checkbox" name="Subject_Requested[]" id="English" value="English" />English
<input type="checkbox" name="Subject_Requested[]" id="Science" value="Science" />Science
<input type="checkbox" name="Subject_Requested[]" id="Maths"  value="Maths" /> Maths
<INPUT type="submit" value="Send">
</form>
----------------
<?php

foreach ($Subject_Requested as $value) {
echo $value.'<br />';
}

?>

and it worked fine?
0
 

Author Comment

by:Refael
ID: 18887719
sakuya_su

the problem is that i have this code inside of the email body....
$body ="foreach ($Subject_Requested as $value) {echo $value.'<br />'};"
it does bot read it ?! you know what i mean?

0
 

Author Comment

by:Refael
ID: 18887727
this is what i get in the email:

foreach (Spanish as ) { echo .'
'; }

i think its because its within the duble quote of the body message.....
0
 

Author Comment

by:Refael
ID: 18887812
i have found the solution.....

outside the body i added:
=======================================
foreach($_POST['Subject_Requested']as $value){
$check_msg.="$value<br>";}
======================================

then in the body i just the $check_msg

work great!
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 19509357
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses how to create an extensible mechanism for linked drop downs.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question