Hello-- Checkbox (HTML) question
Moderator: General Moderators
Hello-- Checkbox (HTML) question
Ladies and gents,
I have emails.php, which is a list of unlimited email addresses, and each email has a "checkbox":
[ ] email@email.com
[ ] email@email.com
[x] email@email.com
[ ] email@email.com
The list count can be anything, since it's spit out from a database. When I submit it to another form for processing, how can I determine which emails are checked?
The html would be like this:
<form name=form1 method=post action=find_checkboxes.php>
<input type="checkbox" name=?????? value="email@email.com"
<input type=submit name=Submit value=Find!>
What would I name it? There will be unlimited amount.
And what would I do on the server side??
$email=$_POST['email'];
But I don't know how many.
Thank you.
I have emails.php, which is a list of unlimited email addresses, and each email has a "checkbox":
[ ] email@email.com
[ ] email@email.com
[x] email@email.com
[ ] email@email.com
The list count can be anything, since it's spit out from a database. When I submit it to another form for processing, how can I determine which emails are checked?
The html would be like this:
<form name=form1 method=post action=find_checkboxes.php>
<input type="checkbox" name=?????? value="email@email.com"
<input type=submit name=Submit value=Find!>
What would I name it? There will be unlimited amount.
And what would I do on the server side??
$email=$_POST['email'];
But I don't know how many.
Thank you.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
use var_dump() on $_POST for an illustration of the structure.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Yes. var_dump() was suggested to give you an illustration of how the information was stored by PHP, nothing more.
-
forum.samir
- Forum Newbie
- Posts: 7
- Joined: Sat Aug 11, 2007 12:55 pm
feyd | Please use
After submitting the form, please try as follows:
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
just try as follows:Code: Select all
$total_email=mysql_num_rows($result_email);
$counter=1;
while($row=mysql_fetch_array($result_email)){
echo "<input type='chekcbox' name='check'.$counter value='{$row[email]}'>";
// checkbox name will be check1, check2 ...
counter++;
}
<input type='hidden' name='total_email' value='$total_email'> //just keep total email in a hidden fieldAfter submitting the form, please try as follows:
Code: Select all
for($i=1;$i<=$count;$i++){
if(isset($_POST['check'.$i])) $email=$_POST['check'.$i]; // $email is a checked email
}feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm