PHP - reading checkboxes

Posted on 2006-11-09
Last Modified: 2008-03-17
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 ===

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,

Question by:sydron
  • 2
  • 2
LVL 15

Expert Comment

ID: 17912200
whats the exact problem are u facing

Author Comment

ID: 17912226
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?
LVL 15

Accepted Solution

babuno5 earned 125 total points
ID: 17912257
$chkexpert = $_REQUEST['chkexpert'];
$hidSubmit = $_REQUEST['hidSubmit'];
for($i=0;$i<$count;$i++){$strExpert="$strExpert$chkexpert[$i], ";}

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

Author Comment

ID: 17913169
Hi babuno5,

Thanks for your solution.

It worked.


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now