6321Re: [NH] HTML radio button forms with submission capability
- Apr 26, 2008Hi Mike,
> Multiple selections.Here's an extended version of the first. Caution: No whitespace or extra
> To be specific: This would be a list of birds. The birds observed would
> be checked off in the form and then a list of the birds checked off
> would be generated on submission.
> To make it more useful I guess it should have entry boxes for the
> location, time , date and observer as well.
> The file would need to be saved to the client.
lines before the opening <?php, or else the script fails with an error
that headers are already sent!
# form has been submitted:
if( count( @$_POST['birds'] ) > 0 )
$birdlist = '';
# build list from form fields:
foreach( $_POST['birds'] as $bird )
$birdlist .= "$bird\r\n";
# send as file to client
header( 'Content-type: application/text' );
# make filename with date
header( 'Content-Disposition: attachment; filename=birdlist_' .
date('Ymdhis') . '.txt' );
exit; # finish processing
<form method="post" action="<?=$_SERVER['PHP_SELF']?>">
<ul style="list-style-type: none;">
<input type="checkbox" name="birds" value="Sparrow" />
<input type="checkbox" name="birds" value="Wren" />
<input type="submit" value="Send" />
To submit more information, you'd have to extend the form.
I'd send a more distinguished example for the processing, but I'm
running out of time today, sorry.
- << Previous post in topic