Hi guyz, I am new in PHP.So I hope someone helps me.I have first page called index.html.In that page there are few checkboxes :
<form action="process.php">
<input type="checkbox" name="mail[]" value="1"> mail to user 01</br>
<input type="checkbox" name="mail[]" value="2"> mail to user 02</br>
<input type="checkbox" name="mail[]" value="3"> mail to user 03</br>
<input type="submit" name="Submit">
</form>
When the submit button will be pressed it should send all checked checkbox values to file process.php.Now I want that process.php will send emails to all checked users.How should process.php look like?I found on internet that it should be done with these brackets [] and with arrays.
Thanks for all answers....
Beginner - How to process more checkboxes - arrays?
Moderator: General Moderators
-
yerupalleyskumar
- Forum Newbie
- Posts: 8
- Joined: Wed Mar 17, 2004 11:04 pm
- Location: Tokyo
- Contact:
<form action="process.php">
<input type="checkbox" name="mail[]" value="1"> mail to user 01</br>
<input type="checkbox" name="mail[]" value="2"> mail to user 02</br>
<input type="checkbox" name="mail[]" value="3"> mail to user 03</br>
<input type="submit" name="Submit">
</form>
in php u can submit the values of check box values by submitting the form by POST mehtod
like
<form action="process.php" method="POST">
and in php
$_POST['mail'] will give the array of mailuser ids
hope this will help
<input type="checkbox" name="mail[]" value="1"> mail to user 01</br>
<input type="checkbox" name="mail[]" value="2"> mail to user 02</br>
<input type="checkbox" name="mail[]" value="3"> mail to user 03</br>
<input type="submit" name="Submit">
</form>
in php u can submit the values of check box values by submitting the form by POST mehtod
like
<form action="process.php" method="POST">
and in php
$_POST['mail'] will give the array of mailuser ids
hope this will help
hmm, not quite sure
I was trying to do it but it was not working for me.I dont know how exactly to do it.Could please someone be more specificaly?
Look at this please
index.html:
process.php:
It is saying always server error in line where is mail function.
please help
Code: Select all
<form action="process.php" method="POST">
<input type="checkbox" name="mailї]" value="user1@domain.sk;"> mail to user 01</br>
<input type="checkbox" name="mailї]" value="user2@domain.sk"> mail to user 02</br>
<input type="submit" name="Submit">
</form>Code: Select all
<?php
// check to be sure at least one option was selected
$mail = $_POSTї'mail'];
if (count($mail) > 0) {
// loop through the array
for ($i=0;$i<count($mail);$i++) {
// do something - this can be a SQL query, echoing data to the browser, or whatever
echo "<li>$mailї$i] \n";
mail("$mailї$i]","blablabla","message","From: administrator@domain.sk");
} // end "for" loop
} // endif
?>please help
problem solved
<?php
// check to be sure at least one option was selected
$mail = $_POST['mail'];
if (count($mail) > 0) {
// loop through the array
for ($i=0;$i<count($mail);$i++) {
// do something - this can be a SQL query, echoing data to the browser, or whatever
echo "<li>$mail[$i] \n";
$to="$mail[$i]";
mail("$to","blablabla","message","From: administrator@domain.sk");
} // end "for" loop
} // endif
?>
// check to be sure at least one option was selected
$mail = $_POST['mail'];
if (count($mail) > 0) {
// loop through the array
for ($i=0;$i<count($mail);$i++) {
// do something - this can be a SQL query, echoing data to the browser, or whatever
echo "<li>$mail[$i] \n";
$to="$mail[$i]";
mail("$to","blablabla","message","From: administrator@domain.sk");
} // end "for" loop
} // endif
?>