Jump to content

checkbox


rafal
Go to solution Solved by 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>
Edited by rafal
Link to comment
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'"; ?>>
  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.