Solved

PHP - reading checkboxes

Posted on 2006-11-09
4
183 Views
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 ===  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
Comment
Question by:sydron
  • 2
  • 2
4 Comments
 
LVL 15

Expert Comment

by:babuno5
ID: 17912200
whats the exact problem are u facing
0
 

Author Comment

by:sydron
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?
0
 
LVL 15

Accepted Solution

by:
babuno5 earned 125 total points
ID: 17912257
<?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
 

Author Comment

by:sydron
ID: 17913169
Hi babuno5,

Thanks for your solution.

It worked.

Cheers,
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

759 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

20 Experts available now in Live!

Get 1:1 Help Now