Jump to content

checkbox


rafal

Recommended Posts

hallo everybody,

i have column in my guestbook table mysql database names vis.

i want make it possible for user to make theier comments invisible.

if user checked yes, the comment will be viewd. if he did not checked, the comment will not be viewed.

in my visibility.php the user can later change the value from yes to no or from no to yes.

i do not know how to make this possible in update.php file.

thank you very much for your help.

Rafal

 

here is my code which not work in visibility.php

<form action="update.php" method="post">
<input type="hidden" name="inp_id" value="<?php echo  $row[id) ?>">
visible: <input type="checkbox" name="inp_vis" <?php if ($row[vis] == "yes") { echo "value='yes' checked"; } else { echo "value='no'"; } ?>>
<br>
<input type="submit" value="Save">
</form>
Link to comment
https://forums.phpfreaks.com/topic/291274-checkbox/
Share on other sites

As to your code, you do not change the value of the checkbox. And, in this case the value really isn't important. The checkbox should use the same value and you should check/uncheck it based upon the saved data. Also, you should save the value as a numeric equivalent of a Boolean, i.e. 0 (false) or 1 (true).

 

 

visible: <input type="checkbox" name="inp_vis" value="visible" <?php echo if ($row['vis']) "checked='checked'"; ?>>
Link to comment
https://forums.phpfreaks.com/topic/291274-checkbox/#findComment-1492070
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.