Hello,

I have a two steps form. first one sends values to a php form (including multiple checkbox values: type[] ) and shows what the user has filled in:

<?php echo $first_name ?>

and so on...
for the checkbox values I used a loop:

<?php  

$count=count($type); 
for ($i=0; $i<$count; $i++){ 
echo "<br>".$type[$i]; 
} 

?> 

The next step is to send the form, and this is where I'm stuck.
How to loop a POST command like:

'.$_POST['first_name'].'

on the checkboxes???

    I used this method I'd read about when I first started programming PHP
    <input type=checkbox name=mychecks[]>Include this item
    <input type=checkbox name=mychecks[]>Use bold font
    <input type=checkbox name=mychecks[]>Existing customer

    Etc.

    What I found was that I needed a scorecard to later figure out what I was handling:
    if($mychecks[0]{
    includethis();
    }
    if($mychecks[1]){
    boldthis(mystring);
    }
    if($mychecks[2]){
    $existingcustomer=1;
    }

    etc.
    But this meant that I had to adjust the colding everytime I changed the interface. If I moved checkbox 1 and 2 for example. I also had to change the if statement:
    if($mychecks[1]{
    includethis();
    }
    if($mychecks[0]){
    boldthis(mystring);
    }

    Better is:
    <input type=checkbox name=mychecks['include']>Include this item
    <input type=checkbox name=mychecks['bold']>Use bold font
    <input type=checkbox name=mychecks['existing']>Existing customer

    Then they could be moved with no change to a code like:
    if($mychecks['include']{
    includethis();
    }
    After a while I got tired of writing the array pieces, so my code is more like:

    <input type=checkbox name=existing>Existing customer
    then:
    if($existing){
    $existingcustomer=1;
    }

    Of course I leave register globals on, so shoot me.

    If off, I'd be saying:
    $mychecks=$_POST['mychecks'];

    etc

      Write a Reply...