At 12:01 PM -0500 10/22/07, Adam Williams wrote:
I have an html page with checkboxes:
<form action=mailform2.php method=POST>
<input type=checkbox name=option[] value="Modern Mississippi">Modern
Mississippi<br>
<input type=checkbox name=option[] value="Civil Rights">Civil Rights<br>
<input type=checkbox name=option[] value="Military
History">MilitaryHistory<br>
<input type=submit name=submit value=Submit>
and mailform2.php containing:
echo "you selected: <br>";
/* line 81 */ foreach ($_POST[option] as $a)
{
echo "$a";
}
but I'm getting the error:
you selected:
*Warning*: Invalid argument supplied for foreach() in
*/var/www/sites/mdah-test/museum/mmhsurvey/mailform2.php* on line
*81*
I googled some checkbox/foreach pages on google, but I don't see
where I'm going wrong. I'm running php 5.2.5 on Apache 2.2.4 on
Fedora Linux. Any help?
There's nothing wrong with your php code, but there is something
wrong with your html and methodology.
First, always use quotes in html for attributes and values (i.e.,
type="checkbox" value ="Submit").
Second, always plan for what the user may do (IOW clean your input).
If "none of the above" is an acceptable answer, then plan for it.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php