Refael
asked on
php form to email with checkboxes
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..........
<input type="checkbox" name="Subject_Requested[]"
<input type="checkbox" name="Subject_Requested[]"
<input type="checkbox" name="Subject_Requested[]"
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..........
ASKER
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?
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?
ASKER
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.....
foreach (Spanish as ) { echo .'
'; }
i think its because its within the duble quote of the body message.....
ASKER
i have found the solution.....
outside the body i added:
========================== ========== ===
foreach($_POST['Subject_Re quested']a s $value){
$check_msg.="$value<br>";}
========================== ========== ==
then in the body i just the $check_msg
work great!
outside the body i added:
==========================
foreach($_POST['Subject_Re
$check_msg.="$value<br>";}
==========================
then in the body i just the $check_msg
work great!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<form action="test.php" method="post">
<input type="checkbox" name="Subject_Requested[]"
<input type="checkbox" name="Subject_Requested[]"
<input type="checkbox" name="Subject_Requested[]"
<INPUT type="submit" value="Send">
</form>
----------------
<?php
foreach ($Subject_Requested as $value) {
echo $value.'<br />';
}
?>
and it worked fine?