Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

PHP - reading checkboxes

Hi all,

I am having difficulty with reading the multiple check box array values from a form.

I have searched this forum and copied and pasted WORKING code but this did not work for me.

I have copied and pasted, a working copy of process from ===  http://www.smartwebby.com/PHP/Phptips2.asp

BUT this does not work for me.

Checkboex have exactly the same syntax as supposed working versions of similar scripts. But i cannot get it to work.


Any ideas,

Cheers
0
sydron
Asked:
sydron
  • 2
  • 2
1 Solution
 
babuno5Commented:
whats the exact problem are u facing
0
 
sydronAuthor Commented:
well i dont get the results displayed at all...the string is empty

and i try to echo $count(thearray) and it gives me 0.....

am i missing something here?
0
 
babuno5Commented:
<?php
print("<pre>");
print_r($_REQUEST);
$chkexpert = $_REQUEST['chkexpert'];
$hidSubmit = $_REQUEST['hidSubmit'];
$strExpert="";
if(isset($hidSubmit)){
$count=count($chkexpert);
for($i=0;$i<$count;$i++){$strExpert="$strExpert$chkexpert[$i], ";}
}
?>

<form name="form1" method="post" action=""> <table width="100%" border="0" bgcolor="#D6E3F7">
<tr>
<td class="text">Your are Expertise field: </td>
</tr>
<tr>
<td class="examplelink">
<input type="checkbox" name="chkexpert[]" value="Java">
Java
<input type="checkbox" name="chkexpert[]" value="PHP">
PHP
<input type="checkbox" name="chkexpert[]" value="ASP">
ASP
<input type="checkbox" name="chkexpert[]" value=".NET">
.NET
<input type="checkbox" name="chkexpert[]" value="JavaScript">
JavaScript</td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Submit">
<input name="hidSubmit" type="hidden" id="hidSubmit2" value="true"></td>
</tr>
<tr>
<td class="subtitlesmall"><p>Result:</p>
<p><span class="reditalic">Your Expertise field: <?php echo $strExpert; ?></span></p></td>
</tr>
<tr>
<td class="reditalic">&nbsp; </td>
</tr>
</table>
</form>
0
 
sydronAuthor Commented:
Hi babuno5,

Thanks for your solution.

It worked.

Cheers,
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now