Jump to content

checkbox help


angel2006

Recommended Posts

your database setting is fine (that's what I use) -- but remember that an unchecked checkbox will not show up in your $_POST or $_GET variables.

So, you will have to accommodate the fact that a variable might not come across.

something like[code]if(!is_set($_POST['checkbox'])) $_POST['checkbox']=0;[/code]

Lately, I've been using radio or select groups with a yes and no option.
Link to comment
Share on other sites

if you are giving people either a yes or no option, you want to use a radio button. It would make life easier for you.

[code]<form method='post' action='code.php'>

<input type='radio' name='decidethis' value='1'>Yes<br>
<input type='radio' name='decidethis' value='0'>No<br>

<input type='submit' name='doit' value='Do It!'>

</form>[/code]

code.php:

[code]if(($_POST['doit'] > '') && ($_POST['decidethis'] >''))

{

$table = 'your_table';

$column = 'your_column';

$answer = $_POST['decidethis'];

mysql_query("INSERT INTO $table ($column) VALUES ($answer) WHERE id = '$current_user[id]'");

}[/code]

...Something to that effect. Good luck buddy.
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.