Checkbox y PHP
Necesito sacar el valor en boleano de si un ceckbos esta pulsado o no, y depende de si esta pulsado que haga algo.
Por ejemplo, se trata de un boletin en el que hay la posibilidad de recibirlo en castellano o en valenciuano, entonces hay dos checkbox, uno para cada idioma. Como podría hacer esto???.
Un saludo y gracias de adelantado
Por ejemplo, se trata de un boletin en el que hay la posibilidad de recibirlo en castellano o en valenciuano, entonces hay dos checkbox, uno para cada idioma. Como podría hacer esto???.
Un saludo y gracias de adelantado
Mira a ver si te sirve este ejemplo:
<table border="0" cellspacing="0" cellpadding="0">
<tr class="t2">
<td align="left"><input name="can1" type="checkbox" value="1"> <? $result=mysql_query("select nombre from idiomas where id='1'",$link); $row=mysql_fetch_array($result); echo($row[nombre]);?></td>
</tr>
<tr class="t2">
<td align="left"><input name="can2" type="checkbox" value="1"> <? $result=mysql_query("select nombre from idiomas where id='2'",$link); $row=mysql_fetch_array($result); echo($row[nombre]);?></td>
</tr>
</table>
<?
$cantotal=$can1+$can2;
$friki=$cantotal;
if ($friki!="1"){
echo(">> Selecciona 1 opción para que tu elección se considere válida. INTÉNTALO DE NUEVO. <<");
}
else {
if ($can1=="1") {
mysql_query("update usuarios set idioma=1 where usr='$authusr'",$link);
}
if ($can2=="1") {
mysql_query("update usuarios set idioma=2 where usr='$authusr'",$link);
}
}
?>
<table border="0" cellspacing="0" cellpadding="0">
<tr class="t2">
<td align="left"><input name="can1" type="checkbox" value="1"> <? $result=mysql_query("select nombre from idiomas where id='1'",$link); $row=mysql_fetch_array($result); echo($row[nombre]);?></td>
</tr>
<tr class="t2">
<td align="left"><input name="can2" type="checkbox" value="1"> <? $result=mysql_query("select nombre from idiomas where id='2'",$link); $row=mysql_fetch_array($result); echo($row[nombre]);?></td>
</tr>
</table>
<?
$cantotal=$can1+$can2;
$friki=$cantotal;
if ($friki!="1"){
echo(">> Selecciona 1 opción para que tu elección se considere válida. INTÉNTALO DE NUEVO. <<");
}
else {
if ($can1=="1") {
mysql_query("update usuarios set idioma=1 where usr='$authusr'",$link);
}
if ($can2=="1") {
mysql_query("update usuarios set idioma=2 where usr='$authusr'",$link);
}
}
?>
