Checkbox update problem... Newbie

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gmtongar
Forum Newbie
Posts: 2
Joined: Sat Dec 20, 2003 10:54 am

Checkbox update problem... Newbie

Post by gmtongar »

Hi,
Trying to teach myself PHP, but ran into a little problem which I haven't been able to solve. I don't think it's a big problem, but for the moment it's a bit above my head and I need some guidance here... Please. My form consist of four checkboxes, those selected are suppose to remain checked after the user click "submit". The thing is that I don't capture the values in a correct fashion. Take a look please...

Code: Select all

<FORM ACTION = "?PHP $_SERVER&#1111;'PHP_SELF] ;?>" METHOD = "GET">
    <INPUT TYPE = "CHECKBOX" NAME = "profile&#1111;]"
      <?PHP IF($profile == "on")&#123;ECHO checked;&#125;?>>
        <?PHP echo $String1 ;?><BR>
    <INPUT TYPE = "CHECKBOX" NAME = "profile&#1111;]"
      <?PHP IF($profile == "on")&#123;ECHO checked;&#125;?>>
        <?PHP ECHO $String2 ;?><BR>
    <INPUT TYPE = "CHECKBOX" NAME = "profile&#1111;]"
      <?PHP IF($profile == "on")&#123;ECHO checked;&#125;?>>
        <?PHP ECHO $String3 ;?><BR>
    <INPUT TYPE = "CHECKBOX" NAME = "profile&#1111;]"
      <?PHP IF($profile == "on")&#123;ECHO checked;&#125;?>>
        <?PHP ECHO $String4 ;?><BR>
    <INPUT TYPE = "SUBMIT" NAME = "submit" VALUE = "Update">
  </FORM>

  <?PHP IF($submit)&#123;    
    for($i = 0; $i < count($profile); $i++)&#123; 
      if(isset($profile&#1111;$i])&#123;
        $profile = "on" ;
      &#125;
    &#125; 
  &#125;
  ;?>
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

Heres a little tutorial with some tips on using checkboxes in forms:
http://codewalkers.com/tutorials/12/4.html
gmtongar
Forum Newbie
Posts: 2
Joined: Sat Dec 20, 2003 10:54 am

Post by gmtongar »

Thanks.

gmtongar
Post Reply