Checkbox Help

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
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

Checkbox Help

Post by AliasBDI »

I have looked at the other threads regarding checkboxes but found none which assist me. I have an update form which displays a user's information and allows them to change. One thing to change is the subscription status. If "yes" they check the box and if "no" they uncheck it. Here is the code I have so far:

Code: Select all

<input type="checkbox" name="newsletter" value="1"   <?php echo checked($newsletter == "1") ?>>
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

how about:

<input type="checkbox" name="newsletter" value="1" <?php if ($newsletter == "1") echo "checked=\"checked\"" ?>>
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

super

Post by AliasBDI »

That did it! Thanks.
Post Reply