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
https://forums.phpfreaks.com/topic/7997-checkbox-help/#findComment-29170
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
https://forums.phpfreaks.com/topic/7997-checkbox-help/#findComment-29172
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.