Forum Moderators: coopster

Message Too Old, No Replies

checkBox values

Unable to get checkBox values

         

dan420

11:12 am on Feb 17, 2006 (gmt 0)

10+ Year Member



Hello All,

I am running PHP5 and apache2. I am new to php.
I am unable to get the check box values in the target page. I have posted the code, could you help me?

//test_chk1.php
------------------------------------------
<FORM ACTION="test_chk.php" METHOD=POST>
<P> Please tell us what you thought of this Web site. Select the checkboxes which you agree with: </P>
<UL>
<LI><inPUT TYPE=checkbox NAME="opinion[]" value="understandable">
The text was understandable.
<LI><inPUT TYPE=checkbox NAME="opinion[]" value="navigable">
I found it easy to find my way through the Web site.
<LI><inPUT TYPE=checkbox NAME="opinion[]" value="stylish">
I was impressed by the style and presentation.
</UL>
<P> <inPUT TYPE="HIDDEN" NAME="pages" value="brochure">
Please add any other comments:
<TEXTAREA NAME="feedback" ROWS=5 COLS=40>
I think your brochure is:
</TEXTAREA>
</P>
<P> <inPUT TYPE=SUBMIT value="Send comments">
<inPUT TYPE=RESET value="Clear form"> </P>
</FORM>
-------------------------------------------

//test_chk.php

<?php
require ("grab_globals.lib.php");
// print $HTTP_POST_VARS['opinion''];
foreach ($$_POST[$opinion] as $val)
{
$toto .= "'" . $val . "'" . "," ;
}
print substr($toto,0,(strlen($toto)-1)) ;
?>

thanks in advance for your help

dan420

11:15 am on Feb 17, 2006 (gmt 0)

10+ Year Member



Sorry here is the correct version

//test_chk.php

<?php

foreach ($opinion as $val)
{
$toto .= "'" . $val . "'" . "," ;
}
print substr($toto,0,(strlen($toto)-1)) ;
?>

dan420

12:57 pm on Feb 17, 2006 (gmt 0)

10+ Year Member



any help

vevs

2:30 pm on Feb 17, 2006 (gmt 0)

10+ Year Member



i tested this and it works

<FORM ACTION="test_chk.php" METHOD=POST>
<P> Please tell us what you thought of this Web site. Select the checkboxes which you agree with: </P>
<UL>
<LI><inPUT TYPE=checkbox NAME="opinion[]" value="understandable">
The text was understandable.
<LI><inPUT TYPE=checkbox NAME="opinion[]" value="navigable">
I found it easy to find my way through the Web site.
<LI><inPUT TYPE=checkbox NAME="opinion[]" value="stylish">
I was impressed by the style and presentation.
</UL>
<P> <inPUT TYPE="HIDDEN" NAME="pages" value="brochure">
Please add any other comments:
<TEXTAREA NAME="feedback" ROWS=5 COLS=40>
I think your brochure is:
</TEXTAREA>
</P>
<P> <inPUT TYPE=SUBMIT value="Send comments">
<inPUT TYPE=RESET value="Clear form"> </P>
</FORM>
-------------------------------------------

//test_chk.php

<?php
foreach ($_POST["opinion"] as $val)
{
$toto .= "'" . $val . "'" . "," ;
}
echo $toto;
?>