Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PHP - reading checkboxes

Posted on 2006-11-09
4
Medium Priority
?
198 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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 …

721 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