[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 744
  • Last Modified:

PHP Sticky checkboxes

I have a form with a series of checkboxes. If the user does not complete other information on the form, user submits, the form is redisplayed and I want the completed fields to be sticky. (I think that is the right term fields already completed to redisplay) including the checkboxes.

<input type="checkbox" name='otherMarketing[]' value="membership" id="membership"  <?php if ($_REQUEST[otherMarketing][membership]=='membership') { echo "checked";} ?> />
                  
0
MarleneAyers
Asked:
MarleneAyers
1 Solution
 
snoyes_jwCommented:
You'd have to name the checkbox 'otherMarketing[membership]' for that to work as written.
0
 
RoonaanCommented:
Or use:

<?php if(in_array('membership',$_REQUEST['otherMarketing'])) { echo 'checked="checked"';} ?>

-r-
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now